<p>Convert a non-negative integer <code>num</code> to its English words representation.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> num = 123
<strong>Output:</strong> &quot;One Hundred Twenty Three&quot;
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> num = 12345
<strong>Output:</strong> &quot;Twelve Thousand Three Hundred Forty Five&quot;
</pre>

<p><strong class="example">Example 3:</strong></p>

<pre>
<strong>Input:</strong> num = 1234567
<strong>Output:</strong> &quot;One Million Two Hundred Thirty Four Thousand Five Hundred Sixty Seven&quot;
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>0 &lt;= num &lt;= 2<sup>31</sup> - 1</code></li>
</ul>

class Solution {
public:
    vector<string> ones = {"One", "Two","Three","Four","Five","Six","Seven","Eight","Nine"};
    vector<string> teens = {"Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"};
    vector<string> tens = {"Ten", "Twenty", "Thirty","Forty", "Fifty","Sixty","Seventy","Eighty","Ninety"};
    string numberToWords(int num) {
        if(num ==0 ) return "Zero";
        stringstream ans;
        while( num > 0 ) {
            cout << num << endl;
            if( num >= 1e9) {
                int billions = num / 1e9;
                ans << ones[billions-1] << " Billion ";
                num = num %(int)1e9;
            } else if( num >= 1e6) {
                int millions = num / 1e6;
                ans << convert(millions) << "Million ";
                num = num % (int)(1e6);
                cout << num << endl;
            } else if ( num >= 1e3) {
                int thousands = num / 1e3;
                ans << convert(thousands) << "Thousand ";
                num = num %(int)1e3;
            } else {
                ans << convert(num);
                num = 0;
            }
        }
        string ret = ans.str();
        ret.pop_back();
        return ret;
    }
    //converts 3 digits num
    string convert(int num) {
        stringstream ans;
        while( num >0) {
            if(num >= 100) {
                int hundreds = num /100;
                ans << ones[hundreds-1] << " Hundred ";
                num = num % 100;
            } else if( num >= 11 && num <=19 ) {
                ans << teens[num - 11] << " ";
                num = 0;
            } else if(num >= 10 ) {
                int cnt = num /10;
                ans << tens[cnt-1] << " ";
                num = num%10;
            } else {
                ans << ones[num-1] << " ";
                num = 0;
            }
        }
        return ans.str();
    }
};
12900