Python solution using re


  • 0
    M

    Using regular expression

    p = "[+-]?(\d+(\.\d*)?|(\.\d+))(e[+-]?\d+)?"
    s = s.strip()
    if s == "":
        return False
    else:
        ret = re.match(p, s)
        return True if ret and ret.group(0) == s else False
    

Log in to reply
 

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