Skip to main content

90. Integer to English Words

hardAsked at Workday

Convert a non-negative integer to its English-words representation. Workday uses this for grouping/edge-case discipline — same shape as generating human-readable payslip amounts ($1,234,567 -> 'One Million Two Hundred Thirty Four Thousand...').

By Alex Chen, Founder, InterviewChamp.AI · Last verified

Source citations

Public interview reports confirming this problem appears in Workday loops.

  • Glassdoor (2026-Q1)Workday payroll-team onsite — direct domain analogy.

Problem

Convert a non-negative integer num to its English words representation.

Constraints

  • 0 <= num <= 2^31 - 1

Examples

Example 1

Input
num = 123
Output
"One Hundred Twenty Three"

Example 2

Input
num = 12345
Output
"Twelve Thousand Three Hundred Forty Five"

Example 3

Input
num = 1234567
Output
"One Million Two Hundred Thirty Four Thousand Five Hundred Sixty Seven"

Approaches

1. Hardcode each magnitude

Long switch statement with ranges 1-9, 10-19, 20-99, etc.

Time
O(log10 n)
Space
O(1)
// massive switch — works but unmaintainable

Tradeoff: Hard to extend.

2. Group by thousands + recursive < 1000 helper

Helper converts 0-999 to words. Main loop handles each thousands group with the right suffix.

Time
O(log10 n)
Space
O(log10 n)
function numberToWords(num) {
  if (num === 0) return 'Zero';
  const ones = ['','One','Two','Three','Four','Five','Six','Seven','Eight','Nine','Ten','Eleven','Twelve','Thirteen','Fourteen','Fifteen','Sixteen','Seventeen','Eighteen','Nineteen'];
  const tens = ['','','Twenty','Thirty','Forty','Fifty','Sixty','Seventy','Eighty','Ninety'];
  function under1000(n) {
    if (n === 0) return '';
    if (n < 20) return ones[n];
    if (n < 100) return tens[Math.floor(n / 10)] + (n % 10 ? ' ' + ones[n % 10] : '');
    return ones[Math.floor(n / 100)] + ' Hundred' + (n % 100 ? ' ' + under1000(n % 100) : '');
  }
  const groups = ['', 'Thousand', 'Million', 'Billion'];
  let result = '';
  let i = 0;
  while (num > 0) {
    if (num % 1000 !== 0) {
      result = under1000(num % 1000) + (groups[i] ? ' ' + groups[i] : '') + (result ? ' ' + result : '');
    }
    num = Math.floor(num / 1000);
    i++;
  }
  return result;
}

Tradeoff: Helper handles 0-999. Main loop chunks by 1000. The 'if (num % 1000 !== 0)' guard prevents 'One Million Thousand' when middle groups are zero.

Workday-specific tips

Workday LOVES this for payroll. Walk through edge cases out loud: 0 ('Zero'), numbers with internal zero groups (1_000_001 should NOT include 'One Thousand'), teens vs tens. Mention the helper-by-1000 decomposition as the modular structure.

Common mistakes

  • Including 'Thousand' for zero groups (1_000_001 -> 'One Million One Thousand One').
  • Special-casing teens with tens digit handling instead of unified lookup.
  • Trailing or leading spaces.

Follow-up questions

An interviewer at Workday may pivot to one of these next:

  • Localize to other languages (German compound nouns!).
  • Support negative numbers.
  • Roman numerals (LC 12/13).

Solve it now

Free. No sign-up. Python and JavaScript run instantly in your browser.

Output

Press Run or Cmd+Enter to execute

FAQ

Why a helper for under 1000?

1000-group structure repeats: ones-hundreds-tens. A pure 0-999 helper is reusable for each magnitude (units, thousands, millions, billions).

Why skip zero groups?

Saying 'One Million Zero Thousand' is wrong. The guard around num % 1000 !== 0 omits empty groups.

Practice these live with InterviewChamp.AI

Drill Integer to English Words and other Workday interview questions under real-loop conditions with instant feedback on your reasoning, complexity claims, and code.

Practice these live with InterviewChamp.AI →