Integer to English Words

Hard Topics Company Tags

Convert the nonnegative integer num to English words. Capitalize the first letter of each word, separate words with one space, and use no leading or trailing spaces. Do not include commas, hyphens, or the word "and". Return "Zero" when the input is 0.

Example 1:

Input: num = 0

Output: "Zero"

Explanation: Zero has the single-word representation Zero.

Example 2:

Input: num = 402

Output: "Four Hundred Two"

Explanation: The hundreds digit contributes Four Hundred and the remaining 2 contributes Two. There is no tens word and no and between the parts.

Example 3:

Input: num = 1000007

Output: "One Million Seven"

Explanation: There is one million and seven units, with no thousands or hundreds to name. The result is One Million Seven.

Constraints:

  • 0 <= num <= 2147483647


Topics

Company Tags

Please upgrade to NeetCode Pro to view company tags.