# Question

Formatted question description: https://leetcode.ca/all/273.html

 273	Integer to English Words

Convert a non-negative integer to its english words representation.
Given input is guaranteed to be less than 2^31 - 1.

Example 1:

Input: 123
Output: "One Hundred Twenty Three"

Example 2:

Input: 12345
Output: "Twelve Thousand Three Hundred Forty Five"

Example 3:

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

Example 4:

Input: 1234567891
Output: "One Billion Two Hundred Thirty Four Million Five Hundred Sixty Seven Thousand Eight Hundred Ninety One"



# Algorithm

The highest can only reach billions, and a group of 3 can only handle 4 groups.

Then we need some function to process three groups of numbers

• We need to list all English words from 1 to 19 and put them in an array
• Also list the English words from 20, 30,… to 90 in another array,

Then, a three-digit n, the hundreds digit is expressed as n/100, the last two digits together are expressed as n%100, the tens digit is expressed as n%100/10, and the single digit is expressed as n%10

Then we see if the last two digits are less than 20

• If it is less than, take the word directly from the array
• If it is greater than or equal to 20, then take the ten and one digit words from the two arrays respectively

Then deal with the number on the hundreds, and remember to add Hundred.

Call this helper function four times in the main function, then insert “Thousand”, “Million”, “Billion” in the middle to the corresponding position, and finally check whether there are spaces at the end, delete all spaces, and check the input when returning Whether it is 0, if yes, return’Zero’.

Java