Valid Number
A hard-tier problem at 22% community acceptance, tagged with String. Reported in interviews at Meta and 7 others.
Valid Number is a hard string problem with a 21% acceptance rate, asked repeatedly at Meta, Google, Amazon, Apple, LinkedIn, and other tier-one companies. The premise is deceptively simple: validate whether a string represents a valid number according to specific rules. Most candidates underestimate it. You'll hit edge cases you didn't anticipate, lose time on parsing logic, and run out of mental bandwidth mid-interview. This is exactly where StealthCoder runs invisibly during your live OA and surfaces a working solution in seconds if the pattern slips your mind.
Companies that ask "Valid Number"
Valid Number is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE.
Get StealthCoderThe trick is recognizing that valid number syntax is a state machine, not a regex puzzle. Most engineers try to build validation with nested conditionals or regex, then drown in cases: leading/trailing spaces, signs before digits, decimal points, exponents with their own signs, empty strings after operators. The pattern that works is a finite automaton approach: track what state you're in (before number, in integer, after decimal, in exponent) and what transitions are legal from each state. Common failure: forgetting that exponents can have their own sign, or allowing two decimals in a single number. When you hit this problem live and the state logic tangles, StealthCoder hedges the gap, giving you a working solution to adapt or copy while you stay calm.
Pattern tags
You know the problem.
Make sure you actually pass it.
Valid Number recycles across companies for a reason. It's hard-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Valid Number interview FAQ
Is Valid Number actually asked at top companies now?+
Yes. Meta, Google, Amazon, Apple, and LinkedIn all report it. At 21% acceptance, it's filtering aggressively. Expect it in mid-to-senior phone screens or take-homes where parsing and edge-case rigor matter.
What's the main trick I'm missing if I try brute-force validation?+
Brute-force if-else chains explode with edge cases. The pattern is state machine: define legal states (digits, decimals, exponents, signs) and which transitions are valid. Once you frame it as automaton transitions, the code is compact and handles all 20+ edge cases cleanly.
How much time should I spend on this in a real interview?+
At hard difficulty with 21% pass rate, interviewers expect 25-35 minutes of focused code, not a quick solve. Plan for clarification questions (leading spaces? multiple decimals?), state design, and testing edge cases. Don't rush.
Does this problem test parsing or algorithmic thinking?+
Both, leaning toward parsing and state machine discipline. It's not about a clever algorithm; it's about rigorous case handling and clean design. Companies hire people who can implement messy real-world logic without losing their minds.
What strings trip up most candidates during the interview?+
Strings like '2.', '.5', '2e10', '2e-5', ' 42', '42 ', and '+-5' all expose gaps. The hardest: 'e9' (exponent without leading digits) and '2.2e2e2' (chained exponents). A state machine catches all of them at once.
Want the actual problem statement? View "Valid Number" on LeetCode →