Spell Out a Like Count in English Words for Screen Readers
Last updated: November 29, 2026
Quick Overview
For accessibility, convert a non-negative integer like count below 2^31 into English words, for example 1234567 -> "One Million Two Hundred Thirty Four Thousand Five Hundred Sixty Seven".
Meta
November 29, 20260
0
0 solved
For accessibility, convert a non-negative integer like count below 2^31 into English words, for example 1234567 -> "One Million Two Hundred Thirty Four Thousand Five Hundred Sixty Seven".
A Meta onsite question with simple math but many edge cases, motivated by screen reader text on Facebook and Instagram. Interviewers grade structure: chunking into thousands, a reusable helper for under 1000, and no stray spaces or 'Zero' fragments.
What the Interviewer Expects
- Split the number into 3-digit groups with scale words
- Write a helper for values below 1000
- Handle teens as their own words
- Avoid emitting empty groups like 'Thousand' for 1,000,000
- Special-case zero
- Join words with single spaces
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
- Localize this for languages with different grouping, like Indian lakh and crore.
- Add support for ordinals (First, Twenty Second).
- How would you test this exhaustively?
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: 0 <= n <= 2^31 - 1 (up to Two Billion ...). Output: Title Case words separated by single spaces, no 'and'. Examples: 0 -> "Zero", 20 -> "Twenty", 1000010 -> "One Million Ten"....
High-Level Design
English groups numbers by thousands: process n in chunks of 3 digits from the right, attaching scales '', 'Thousand', 'Million', 'Billion'. For each nonzero chunk, spell it with a helper and append th...