FastPrepSpell a Number From 0 to 999 in English
Problems/Spell a Number From 0 to 999 in English

Spell a Number From 0 to 999 in English

Capital One logoCapital One● EasyINTERNFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Four Capital One reports from 2017 ask for a number to be written out in English words. Three are from intern candidates and one is from a software engineer candidate. One limits the numbers to 0 through 999. The others give three-digit samples written with different capitals and hyphens.

This version takes 0 to 999 and writes lowercase words. It hyphenates compound tens such as sixty-four, and leaves out the word and. These are our choices.

Our version is about 85% the same as the reported questions.

Return how num is said in English, as lowercase words separated by single spaces.

  • Zero is "zero". Each of 1 through 19 has a name of its own, from "one" up to "nineteen".
  • From 20 to 99, say the tens word ("twenty", "thirty", …, "ninety"); if a ones digit remains, attach its name with a hyphen, as in "forty-two".
  • From 100 up, say the hundreds digit's name followed by "hundred", then the words for the remaining two digits unless both are zero. The word "and" never appears.

Function

numberToWords(num: int) → String

Examples

Example 1

num = 718return = "seven hundred eighteen"

7 hundreds, then 18. Numbers from 10 to 19 have their own names, so it is eighteen, not ten-eight.

Example 2

num = 305return = "three hundred five"

The tens digit is 0, so nothing is said for it: three hundred followed straight by five.

Example 3

num = 64return = "sixty-four"

From 21 to 99, a tens word and a ones word are joined by a hyphen when both are present.

Example 4

num = 0return = "zero"

The input 0 is written as zero. That word never appears inside a longer number such as 305.

Example 5

num = 800return = "eight hundred"

The last two digits are 00, so nothing follows hundred: no trailing space and no extra word.

Example 6

num = 70return = "seventy"

The ones digit is 0, so the tens word stands alone, with no hyphen.

Constraints

  • 0 <= num <= 999

More Capital One Onsite Interview questions

  • Digit-Coded Card ValidationONSITE INTERVIEW · Seen Nov 2026
  • Sort ColorsONSITE INTERVIEW · Seen Oct 2026
  • Virtual Card Transaction ValidatorONSITE INTERVIEW · Seen Oct 2026
  • Banking System with Top ActivityONSITE INTERVIEW · Seen Sep 2026
  • Transaction Event StoreONSITE INTERVIEW · Seen Jul 2026
  • Shortest Path in an Unweighted GraphONSITE INTERVIEW · Seen Jul 2026
  • Duplicate Transactions Within 60 SecondsONSITE INTERVIEW · Seen May 2026
  • LRU CachePHONE SCREEN · ONSITE INTERVIEW · Seen May 2026
  • Cashback TrackerONSITE INTERVIEW · Seen Nov 2025
  • Reverse a StringOA · ONSITE INTERVIEW · Seen Oct 2025

Similar questions at other companies

  • Roman to IntegerKotak Mahindra Bank · PHONE SCREEN · ONSITE INTERVIEWKotak Mahindra Bank interview questions
  • Convert Hexadecimal to Dotted IPv4Microsoft · ONSITE INTERVIEWMicrosoft interview questions
  • Palindrome Match PercentageApple · ONSITE INTERVIEWApple interview questions
  • Caesar Cipher with a Precomputed AlphabetAmazon · ONSITE INTERVIEW
  • Add Two Binary StringsPeopleStrong · ONSITE INTERVIEWPeopleStrong interview questions
  • Add Two Numeric Strings with CarryZipRecruiter · ONSITE INTERVIEWZipRecruiter interview questions
  • Substrings Made Only of VowelsExpedia · ONSITE INTERVIEWExpedia interview questions
  • Calculate a Token-List ExpressionCollege Vine · ONSITE INTERVIEW
  • Iterate Canonical IPv6 AddressesOpenAI · ONSITE INTERVIEWOpenAI interview questions
  • Nth Staged License PlateGoogle · ONSITE INTERVIEWGoogle interview questions

Capital One interview experiences

  • Capital One Coding OA Questions: 3 Experiences
  • Capital One Experienced Engineer Power Day and OA: 6 Experiences
  • Capital One New Grad OA Questions: 14 Experiences (Part 2 of 2)
  • Capital One TDP Agentic Round (AI Coding): 7 Experiences
  • Capital One SWE Power Day, Level Not Reported: 6 Experiences
  • Capital One TIP Intern OA and Power Day: 13 Experiences
All Capital One interview questionsSee Capital One hiring insights
Saved
class Solution {
    public String numberToWords(int num) {
        // Write your code here.
    }
}
Checking account…