Code Room
CodingMediumcod-g218
Subject ParsingLevel Mid–Senior~30 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

Write a validator that decides whether a string is a well-formed decimal number under this grammar: an optional leading '+' or '-' sign, then a mantissa, then an optional exponent. The mantissa is either digits, or digits '.' digits, or digits '.', or '.' digits (at least one digit total). The exponent is 'e' or 'E', an optional sign, then one or more digits. No spaces are allowed. Return True if the entire string matches, else False. Examples that are valid: '0', '-3.14', '.5', '2.', '1e10', '+6E-9'. Invalid: '', '.', '1e', 'e3', '1.2.3', '+-1', '1e1.5'.

Implement
is_number(s: str) → bool
Examples
in["-3.14"]outtrue
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.