Medium · Strings
Valid Number
Given a string s, return true if it is a valid number — an optionally signed integer or decimal (such as "7", "7.", ".5" or "-3.25"), optionally followed by 'e' or 'E' and an optionally signed integer — and false otherwise; no spaces or other characters are allowed.
Examples
Example 1
{
"s": "2e-3"
}Output: true
Example 2
{
"s": "1a"
}Output: false
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.