166. validate number string
medium - accepted / - tried
Give a number string, check if it is valid number.
By "valid", we mean if it validates as one of below formats:
- integer, such as
- decimal number like
- exponential notation
Formats such as
NaN, octal and hexadecimal .etc are out of scope, you can treat them as invalid.
Pay attention to the sign
You should confirm with your interviewer about the scope and those edge cases.
isNaN() seems to be a nice trick, but could you solve without it?