Python 3 solution


  • 0
    J

    Use the built-in try-except in Python and the problem becomes easy

    class Solution:
        def isNumber(self, s):
            try:
                _ = float(s)
                return True
            except ValueError:
                return False
    

Log in to reply
 

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