Search⌘ K
AI Features

DIY: Valid Number

Understand how to determine if a string is a valid decimal number by analyzing characters like digits, signs, decimals, and exponents. This lesson helps you implement a validation function to solve common coding interview problems related to number parsing.

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 - "+"/"-" ...