Spell Out an Integer in English Words for Check Printing
Last updated: November 29, 2026
Quick Overview
Convert a non-negative integer below 2^31 into its English words representation, such as 1234567 to "One Million Two Hundred Thirty Four Thousand Five Hundred Sixty Seven".
Microsoft
November 29, 20260
0
0 solved
Convert a non-negative integer below 2^31 into its English words representation, such as 1234567 to "One Million Two Hundred Thirty Four Thousand Five Hundred Sixty Seven".
A long-standing Microsoft onsite question, natural for teams like Dynamics 365 Finance where check printing and invoices need amounts in words. It is rated hard not for algorithmic depth but because the interviewer expects you to decompose cleanly and handle every special case on the first attempt.
What the Interviewer Expects
- Split the number into groups of three digits
- Write one helper that converts 0 to 999
- Attach scale words (Thousand, Million, Billion) to non-zero groups only
- Handle teens and zero correctly
- Avoid double spaces and trailing 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
- How would you add cents and the word "and", as printed on a check?
- How would you localize this for languages with different grouping rules, like Indian lakh and crore?
- How would you convert the words back into a number?
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 is an integer from 0 to 2,147,483,647. Output words are capitalized and separated by single spaces with no hyphens and no "and" (confirm this formatting). Zero is "Zero". Groups that are entirel...
High-Level Design
English reads numbers in groups of three digits, each followed by a scale word. So the problem reduces to one helper for 0 to 999, and a loop that peels off groups with divmod(num, 1000) from least ...