FastPrepInteger to English Words in USD and INR Styles
Problems/Integer to English Words in USD and INR Styles

Integer to English Words in USD and INR Styles

Veeam logoVeeam● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: In the first round, the interviewer asked for a problem like Integer to English Words with one change: the place names depend on the currency. Indian rupees use Crore, Lakh and Thousand, and US dollars use Billion, Million and Thousand. The code also had to make it easy to add new currency formats later.

The report does not give the input type, the number range, or the exact word format. Here num is a 32-bit integer from 0 to 2^31 - 1, the currency comes in as USD or INR, only the number words are returned (no currency name), and words are capitalized with single spaces and no word and. Adding a new currency is discussed in the editorial, and the tests do not check it.

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

Write the non-negative integer num in English words, using the place names of the given currency.

Split num into parts by place value, largest first:

  • For "USD", the places are Billion (1,000,000,000), Million (1,000,000) and Thousand (1,000). For example, 1,234,567 is 1 Million, 234 Thousand and 567.
  • For "INR", the places are Crore (10,000,000), Lakh (100,000) and Thousand (1,000). For example, 1,23,45,678 is 1 Crore, 23 Lakh, 45 Thousand and 678. The number of crores can be 100 or more, such as 214 Crore.

Take as many of the largest place as fit, then as many of the next place as fit in what is left, and so on. The part that is left at the end is below 1,000.

Write each part that is not zero as its count in words followed by the place name, from the largest place to the smallest, and then write the part below 1,000. Skip every part that is zero.

Write a count from 1 to 999 like this: if it is 100 or more, start with the hundreds digit word and Hundred. Then write the rest from 1 to 99, if it is not zero: One to Nineteen for 1 to 19, or a tens word from Twenty to Ninety followed by the ones word when the last digit is not 0.

Every word starts with a capital letter, and words are separated by single spaces. Do not use and, commas or hyphens. If num is 0, return "Zero".

Function

numberToWords(num: int, currency: String) → String

Examples

Example 1

num = 123456789currency = "USD"return = "One Hundred Twenty Three Million Four Hundred Fifty Six Thousand Seven Hundred Eighty Nine"

123,456,789 is 123 Million, 456 Thousand and 789. Written out, that is One Hundred Twenty Three Million, then Four Hundred Fifty Six Thousand, then Seven Hundred Eighty Nine.

Example 2

num = 123456789currency = "INR"return = "Twelve Crore Thirty Four Lakh Fifty Six Thousand Seven Hundred Eighty Nine"

In the Indian system, 123,456,789 is written 12,34,56,789. That is 12 Crore, 34 Lakh, 56 Thousand and 789, so the words are Twelve Crore, Thirty Four Lakh, Fifty Six Thousand and Seven Hundred Eighty Nine.

Example 3

num = 1000010currency = "INR"return = "Ten Lakh Ten"

1,000,010 is written 10,00,010 in the Indian system. That is 10 Lakh, 0 Thousand and 10. The Thousand part is zero, so it is skipped, and the answer is Ten Lakh Ten.

Constraints

  • 0 <= num <= 2^31 - 1
  • currency is "USD" or "INR".

Similar questions at other companies

  • Evaluate an Arithmetic Expression Written in WordsBrex · PHONE SCREEN
  • Reorderable Task Scheduler With CooldownWaymo · PHONE SCREENWaymo interview questions
  • Basic Calculator IISnap Inc. · PHONE SCREENSnap Inc. interview questions
  • Bit at an Index After Repeated Binary ExpansionAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Text Embedding and Vector SearchNike, Inc. · PHONE SCREEN · ONSITE INTERVIEWNike, Inc. interview questions
  • Add Signed Character ArraysByteDance · PHONE SCREENByteDance interview questions
  • Per-Segment SpeedingOnePay · PHONE SCREENOnePay interview questions
  • Evaluate a Flat Expression or Report Invalid InputMeta · PHONE SCREENMeta interview questions
  • Find Accounts with Negative Converted BalancesStripe · PHONE SCREENStripe interview questions
  • Compute TF-IDF ScoresApple · PHONE SCREENApple interview questions
See Veeam hiring insights
Saved
class Solution {
    public String numberToWords(int num, String currency) {
        // Write your code here.
    }
}
Checking account…