Problem
Problem page: https://leetcode.com/problems/valid-number/
Topics: Math, String
Difficulty: hard
Similar problems: (E) String to Integer (atoi)
Validate if a given string is numeric.
Some examples:
"0"=>true
" 0.1 "=>true
"abc"=>false
"1 a"=>false
"2e10"=>trueNote: It is intended for the problem statement to be ambiguous. You should gather all requirements up front before implementing one.
Analysis
A finite automaton (DFA). Come to think of it, could I solve this with an NFA? What are the limits of using an NFA?
Code
1 | class Solution: |
Article link: https://xnerv.wang/en/leetcode-valid-number/
