Parse Spoken Number Words Into an Integer for Voice Input
Last updated: November 29, 2026
Quick Overview
Convert an English number phrase from a speech transcript, such as "two hundred thirty-four thousand five hundred and six" or "minus forty two", into an integer, supporting hundred, thousand, million, and billion, and rejecting phrases with misplaced scale words.
0
0
0 solved
Convert an English number phrase from a speech transcript, such as "two hundred thirty-four thousand five hundred and six" or "minus forty two", into an integer, supporting hundred, thousand, million, and billion, and rejecting phrases with misplaced scale words.
Google Assistant and Gboard voice typing need to turn spoken numbers into digits, which makes this a natural onsite parsing question. The interviewer checks the accumulator design (current group versus running total), validation of scale order, and handling of filler words like and.
What the Interviewer Expects
- Normalizes hyphens, commas, and the filler word and
- Keeps a current group accumulator separate from the running total
- Multiplies the current group by hundred and flushes on thousand, million, billion
- Rejects misplaced scales such as one thousand two million
- Handles negatives and zero
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Support informal forms such as nineteen ninety nine meaning 1999, or a couple hundred.
- Return the digits in the transcript while leaving surrounding words untouched.
- How would you make this locale-aware for French, where 80 is quatre-vingts?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Vocabulary: zero to nineteen, tens words,
hundred,thousand,million,billion, optionaland, leadingminus. two hundred thirty-four thousand five hundred and sixgives234506.- Sc...
High-Level Design
Two accumulators capture the structure of English numbers. current builds the group below a thousand: small and tens words add to it, and hundred multiplies it by 100. A large scale word closes th...