Search⌘ K
AI Features

DIY: Valid Number

Understand how to validate whether a string represents a valid decimal number, including handling signs, decimal points, and exponents. This lesson helps you implement a function to determine number validity, preparing you for coding interview problems on string parsing and input validation.

Problem statement

Validate if a given string can be interpreted as a decimal number or not. Here is a list of characters that can appear in a valid decimal number:

  • Numbers - 0-9

  • Exponent - "e"

  • Positive/negative sign - "+"/"-" ...