InterviewBit Academy is now Scaler!
InterviewBit Academy is now Scaler Academy!

Valid Number

Please Note:

Note: It is intended for some problems to be ambiguous. You should gather all requirements up front before implementing one.

Please think of all the corner cases and clarifications yourself.

Validate if a given string is numeric.


  • "0" => true
  • " 0.1 " => true
  • "abc" => false
  • "1 a" => false
  • "2e10" => true

Return 0 / 1 ( 0 for false, 1 for true ) for this problem

Clarify the question using “See Expected Output”

  • Is 1u ( which may be a representation for unsigned integers valid?
    For this problem, no.

  • Is 0.1e10 valid?

  • -01.1e-10?

  • Hexadecimal numbers like 0xFF?
    Not for the purpose of this problem

  • 3. (. not followed by a digit)?

  • Can exponent have decimal numbers? 3e0.1?
    Not for this problem.

  • Is 1f ( floating point number with f as prefix ) valid?
    Not for this problem.

  • How about 1000LL or 1000L ( C++ representation for long and long long numbers )?
    Not for this problem.

  • How about integers preceded by 00 or 0? like 008?
    Yes for this problem

Start solving Valid Number on Interview Code Editor
Sign Up
to access hints and editorial solutions for Valid Number
Asked In:


Click here to start solving coding interview questions