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
Coding & Algorithms
Software Engineer
Microsoft
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

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
string building
recursion
number formatting
decomposition
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
  • 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 Problems
Sample 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 ...


Submit Your Answer
Markdown supported