Asked in oracle/Amazon


#1

Given number into words.
For example, if “1234” is given as input, output should be “one thousand two hundred and thirty four”.


#2

first make a hash map ->
1- one
2- two
3- three
… so on

make a second hash map ->
10- ten
100 - hundred
1000- thousand
100000 - lakh
… so on

make a third hash map ->
11 - eleven
12- twelve

so on

make a fourth hash map
20 - twenty
30 - thirty
40- fourty
… so on

now the approach is simple take the number divide it with 10 then 100 and so on , till the break condition and see the quotient in the map and then the modulus … I hope the idea is clear