Valid Number

Problem: Valid Number

Actually I use a tricky solution here. Here's a professional solution using DFA.

Code in Python:

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

results matching ""

    No results matching ""