Practice Valid Number
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Return whether s is a valid numeric string. It may begin with + or -. Its main part must be either one or more digits, digits followed by a decimal point with optional following digits, or a decimal point followed by one or more digits. An optional exponent starts with e or E and then contains an optional sign followed by one or more digits. The exponent cannot contain a decimal point. No other characters or extra signs are allowed. Thus 4., -.9 and 3e+7 are valid, while 1e and 99e2.5 are not.
Source: Valid Number on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
s = "0"
true
# Example 2
s = "e"
false
# Example 3
s = "."
false
Constraints
Related LeetCode Problems
Practice more problems similar to Valid Number.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.