5-Line Python solution


  • 0
    Y

    class Solution(object):
    def isNumber(self, s):
    """
    :type s: str
    :rtype: bool
    """
    s.strip()
    try:
    return type(float(s)) == float
    except:
    return False


Log in to reply
 

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