bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
HardMath & GeometryLC 65

Valid Number

A valid number can be split up into these components (in order):

  1. A decimal number or an integer.
  2. (Optional) An 'e' or 'E', followed by an integer. A decimal number can be split up into these components (in order):
  3. (Optional) A sign character (either '+' or '-').
  4. One of the following formats:
  5. One or more digits, followed by a dot '.'.
  6. One or more digits, followed by a dot '.', followed by one or more digits.
  7. A dot '.', followed by one or more digits. An integer can be split up into these components (in order):
  8. (Optional) A sign character (either '+' or '-').
  9. One or more digits. For example, all the following are valid numbers: [ "2 ", "0089 ", "-0.1 ", "+3.14 ", "4. ", "-.9 ", "2e10 ", "-90E3 ", "3e+7 ", "+6e-1 ", "53.5e93 ", "-123.
Asked at 8 companies
AdobeAmazonApple
Hints
  • 1.Think about which data structure fits best
  • 2.Consider the time complexity of your approach
  • 3.Look for patterns in the constraints
LeetCode