PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches

Quick Overview

This question evaluates a candidate's ability to decompose integers and implement precise string-formatting logic, including mapping numeric values to their English word equivalents and managing scale units and boundary conditions.

  • easy
  • Carvana
  • Coding & Algorithms
  • Software Engineer

Spell Out a Nonnegative Integer

Company: Carvana

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Onsite

Given a nonnegative integer, return its English words representation. Implement a function that handles numbers from `0` through `2,147,483,647` inclusive. Requirements: - Return `"Zero"` for input `0`. - Use standard American English scale words: `Thousand`, `Million`, and `Billion`. - Do not include the word `and`. - Use single spaces between words and no leading or trailing spaces. - Capitalize each word as shown in the examples. Examples: - Input: `7` Output: `"Seven"` - Input: `19` Output: `"Nineteen"` - Input: `123` Output: `"One Hundred Twenty Three"` - Input: `1005` Output: `"One Thousand Five"` - Input: `1234567` Output: `"One Million Two Hundred Thirty Four Thousand Five Hundred Sixty Seven"` - Input: `2147483647` Output: `"Two Billion One Hundred Forty Seven Million Four Hundred Eighty Three Thousand Six Hundred Forty Seven"`

Quick Answer: This question evaluates a candidate's ability to decompose integers and implement precise string-formatting logic, including mapping numeric values to their English word equivalents and managing scale units and boundary conditions.

Given a nonnegative integer, return its English words representation. Handle every value from 0 through 2,147,483,647 inclusive. Rules: - Return "Zero" for input 0. - Use standard American English scale words: Thousand, Million, and Billion. - Do not include the word "and". - Use single spaces between words, with no leading or trailing spaces. - Capitalize each word exactly as shown in the examples.

Constraints

  • 0 <= num <= 2147483647
  • Only the scale words Thousand, Million, and Billion are needed
  • Do not use the word "and" anywhere in the output

Examples

Input: (0,)

Expected Output: "Zero"

Explanation: Zero is a special case and should return exactly "Zero".

Input: (7,)

Expected Output: "Seven"

Explanation: Single-digit numbers map directly to their word form.

Input: (19,)

Expected Output: "Nineteen"

Explanation: Numbers from 10 to 19 use unique word forms.

Input: (123,)

Expected Output: "One Hundred Twenty Three"

Explanation: 123 is split into 100 + 20 + 3, with no "and" added.

Input: (1005,)

Expected Output: "One Thousand Five"

Explanation: The thousands group is spoken, and the zero hundreds/tens in the last group are skipped.

Input: (1234567,)

Expected Output: "One Million Two Hundred Thirty Four Thousand Five Hundred Sixty Seven"

Explanation: Split into 1 million, 234 thousand, and 567.

Input: (1000000010,)

Expected Output: "One Billion Ten"

Explanation: Zero million and zero thousand groups are omitted entirely.

Input: (2147483647,)

Expected Output: "Two Billion One Hundred Forty Seven Million Four Hundred Eighty Three Thousand Six Hundred Forty Seven"

Explanation: This is the maximum allowed value and must be decomposed into billions, millions, thousands, and the final three-digit group.

Hints

  1. Break the number into groups of three digits from right to left: ones, thousands, millions, billions.
  2. Write a helper that converts a number from 1 to 999 into words, then attach the correct scale word for each nonzero group.
Last updated: May 15, 2026

Loading coding console...

PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.