Spell Out Integers in English Words for Text-to-Speech Output
Last updated: November 29, 2026
Quick Overview
Convert any integer with absolute value below one quadrillion into its English words form as a text-to-speech engine would read it, for example 1234567 as "one million two hundred thirty-four thousand five hundred sixty-seven", including zero and negatives.
0
0
0 solved
Convert any integer with absolute value below one quadrillion into its English words form as a text-to-speech engine would read it, for example 1234567 as "one million two hundred thirty-four thousand five hundred sixty-seven", including zero and negatives.
Google Assistant and the text-to-speech stack have to verbalize numbers, which makes this a grounded onsite question even though the core is simple. It is rated hard because interviewers grade the details: three-digit grouping, skipping empty groups, hyphenation, zero, negatives, and a test strategy that proves correctness.
What the Interviewer Expects
- Decomposes the number into three-digit groups with scale names
- Writes one helper for 0 to 999 and reuses it for every group
- Skips groups that are zero so 1000010 reads one million ten
- Handles zero, negatives, teens, and hyphenated tens
- Proposes round-trip testing against a words-to-number parser
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
- Produce British English, which inserts and (one hundred and five).
- Verbalize ordinals (twenty-first) and years (nineteen ninety-nine).
- How would you structure this for 40 languages with different grouping rules, such as Indian lakh and crore?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Input: integer
nwith|n| < 10^15. - Output: lowercase American English words: no
and, tens and ones hyphenated (forty-two), scale words thousand, million, billion, trillion. 0iszero...
High-Level Design
English reads numbers in groups of three digits, each followed by a scale word. So the design is a helper that verbalizes 0 to 999 (hundreds digit, then either a teen word, or a tens word with an opti...