A python re solution


  • 0
    G

    import re

    class Solution:
        # @param {string} s
        # @return {boolean}
        def isNumber(self, s):
            return bool(re.match(' *[\+\-]?(((\d*\.?\d+)|(\d+\.?\d*))(e[\+\-]?\d+)?)[ ]*$', s))

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.