@@ -0,0 +1,1412 @@
+'''%0AValidate if a given string is numeric.%0A%0ASome examples:%0A%220%22 =%3E true%0A%22 0.1 %22 =%3E true%0A%22abc%22 =%3E false%0A%221 a%22 =%3E false%0A%222e10%22 =%3E true%0ANote: It is intended for the problem statement to be ambiguous. %0AYou should gather all requirements up front before implementing one.%0A%0AUpdate (2015-02-10):%0AThe signature of the C++ function had been updated. If you still see your %0Afunction signature accepts a const char * argument, please click the reload button  %0Ato reset your code definition.%0A'''%0A%0Aclass Solution:%0A    # @param %7Bstring%7D s%0A    # @return %7Bboolean%7D%0A    def isNumber(self, s):%0A        if not s: return True%0A        has_e = False%0A        has_dot = False%0A        has_number = False%0A        has_numaftere = False%0A        %0A        s = s.strip()%0A        for i, char in enumerate(s):%0A            if char.isdigit():%0A                has_number = True%0A                has_numaftere = True%0A            elif char == 'e':%0A                if has_e or not has_number:%0A                    return False%0A                has_e = True%0A                has_numaftere = False%0A            elif char == '.':%0A                if has_dot or has_e:%0A                    return False%0A                has_dot = True%0A            elif (char == '+') or (char == '-'):%0A                if i != 0 and s%5Bi-1%5D != 'e':%0A                    return False%0A            else:%0A                return False%0A        %0A        return (has_numaftere and has_number)%0A

Create valid_number.py