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.

Google
Coding & Algorithms
Software Engineer
Google
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

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
Decomposition
String Building
Number Formatting
Property-Based Testing
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. 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 Problems
Sample Answer
Requirements
  • Input: integer n with |n| < 10^15.
  • Output: lowercase American English words: no and, tens and ones hyphenated (forty-two), scale words thousand, million, billion, trillion.
  • 0 is zero...
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...


Submit Your Answer
Markdown supported