FastPrepInteger to English Words: Up to 20 Digits
Problems/Integer to English Words: Up to 20 Digits

Integer to English Words: Up to 20 Digits

PeopleStrong logoPeopleStrong● HardFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a PeopleStrong onsite interview. The report asks for number names up to 20 digits and for handling chunks of zeros. It also talks about optional negatives and wording with or without the word and. This version supports negatives and uses international English without the word and. We chose the input format and the exact style. Our version is about 95% the same as the reported question.

Convert the integer represented by the decimal string number into English words. The number can have up to 20 digits, excluding a minus sign. Do not try to store the whole input in a signed 64-bit integer.

For this exercise, assume the input may start with a minus sign and may contain leading zeros. Use the international scales Thousand, Million, Billion, Trillion, Quadrillion and Quintillion. Capitalize each word, separate words with one space, and use no hyphens or the word and. If the number is negative and not zero, begin the result with Negative. Any input whose value is zero returns Zero.

Function

numberToWords(number: String) → String

Examples

Example 1

number = "12345"return = "Twelve Thousand Three Hundred Forty Five"

Split the magnitude into groups 12 and 345, attach Thousand to the first group and spell each nonzero group.

Example 2

number = "10000000000000000001"return = "Ten Quintillion One"

The leading 20-digit group means ten quintillion. Skip the zero-valued intervening groups.

Constraints

  • For this exercise, assume the input matches an optional minus sign followed by 1 through 20 decimal digits.
  • The absolute value is at most 99999999999999999999.
  • The input contains no whitespace or other characters.

More PeopleStrong Onsite Interview questions

  • Add Two Binary StringsONSITE INTERVIEW · Seen Mar 2026
  • Four SumONSITE INTERVIEW · Seen Mar 2026
  • LRU Cache OperationsONSITE INTERVIEW · Seen Mar 2026
  • Sliding Window MaximumONSITE INTERVIEW · Seen Mar 2026
  • Find the Entry of a Linked List CycleONSITE INTERVIEW · Seen Sep 2025
  • Word Ladder II: All Shortest TransformationsONSITE INTERVIEW · Seen Sep 2025
  • Detect a Cycle in a Linked ListONSITE INTERVIEW · Seen May 2025
  • First Nonrepeating CharacterONSITE INTERVIEW · Seen May 2025
  • Longest Subarray with a Target SumONSITE INTERVIEW · Seen May 2025
  • Lowest Common Ancestor in a BSTONSITE INTERVIEW · Seen May 2025

Similar questions at other companies

  • Every Result of Grouping an ExpressionC3.ai · ONSITE INTERVIEWC3.ai interview questions
  • Basic CalculatorAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Nested JSON Schema ValidatorPinterest · ONSITE INTERVIEWPinterest interview questions
  • Toy Language Generic Return-Type InferenceOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Transform L/R Pieces on a Circular BoardGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Validate Nested JSON Against a SchemaBenchling · ONSITE INTERVIEWBenchling interview questions
  • Evaluate an Arithmetic Expression with DivisionMotive · ONSITE INTERVIEWMotive interview questions
  • Validate a Nested Object Against a SchemaConfluent · ONSITE INTERVIEWConfluent interview questions
  • Nearest Palindromic NumberApple · ONSITE INTERVIEWApple interview questions
  • Single-Pass S-Expression ParserBaseten · ONSITE INTERVIEWBaseten interview questions

Interview reports that mention this question

  • PeopleStrong SDE OA and Interview Questions: 12 Experiences
All PeopleStrong interview questionsSee PeopleStrong hiring insights
Saved
class Solution {
    public String numberToWords(String number) {
        // Write your solution here.
    }
}
Checking account…