April 10, 2014
ProblemConvert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1.SolutionAs we know, numbers in every 3 digits can be represented as thousand, million, billion, trillion, quadrillion … According to description, the number is no larger than billions. All remainders are at hundreds level and are easy to represent.class Solution {public: string numberToWords(int num) { if (num == 0) return "Zero"; stack<strin...
OLDER POSTS »