1305. Integer to English Words
class Solution { public : /** * @param num: a non-negative integer * @return: english words representation */ string numberToWords ( int num) { string res = convertHundred(num % 1000 ); vector < string > v = { "Thousand" , "Million" , "Billion" }; for ( int i = 0 ; i < 3 ; ++i) { num /= 1000 ; res = num % 1000 ? convertHundred(num % 1000 ) + " " + v[i] + " " + res : res; } while (res.back() == ' ' ) res.pop_back(); return res.empty() ? "Zero" : res; } string convertHundred ( int num) { vector < string > v1 = { "" , "One" , "Two" , "Three" , "Four" , "Five" , "Six" , "Seven" , "Eight" , "Nine" , "Ten" , "Eleven" , "Twelve" , "Thirteen" ,...