DIY: Integer to English Words

Solve the interview question "Integer to English Words" in this lesson.

Problem statement

Convert a non-negative integer n to its English word representation.

Input

The input will be an integer value. The following is an example input:

123

Output

The output will be a string. The following is an example output:

"One Hundred Twenty Three"

Coding exercise

Implement the number_to_words(n) function, where n is the integer to be converted. The function returns the English word representation of n as a string.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.