<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:
    void Print1(int x, stringstream &ss){
        switch (x) {
                case 1 : ss << "One "; break;
                case 2 : ss << "Two "; break;
                case 3 : ss << "Three "; break;
                case 4 : ss << "Four "; break;
                case 5 : ss << "Five "; break;
                case 6 : ss << "Six "; break;
                case 7 : ss << "Seven "; break;
                case 8 : ss << "Eight "; break;
                case 9 : ss << "Nine "; break;
        }
    }
    void Print3(int x, stringstream &ss) {

        if (x / 100 > 0)  {
            Print1(x/100, ss); ss <<"Hundred ";
            x = x % 100;
        }

        if ( x / 10 == 1) {
            switch (x) {
                case 10 : ss << "Ten "; break;
                case 11 : ss << "Eleven "; break;
                case 12 : ss << "Twelve "; break;
                case 13 : ss << "Thirteen "; break;
                case 14 : ss << "Fourteen "; break;
                case 15 : ss << "Fifteen "; break;
                case 16 : ss << "Sixteen "; break;
                case 17 : ss << "Seventeen "; break;
                case 18 : ss << "Eighteen "; break;
                case 19 : ss << "Nineteen "; break;
            }
            return;
        }

        if (x / 10 > 1) {
            switch (x/10) {
                case 2 : ss << "Twenty "; break;
                case 3 : ss << "Thirty "; break;
                case 4 : ss << "Forty "; break;
                case 5 : ss << "Fifty "; break;
                case 6 : ss << "Sixty "; break;
                case 7 : ss << "Seventy "; break;
                case 8 : ss << "Eighty "; break;
                case 9 : ss << "Ninety "; break;
            }
            x = x%10;
        }
        Print1(x, ss);
    }

    string numberToWords(int num) {
        if (num == 0) return "Zero";

        stringstream ss;

        int x = num % 1000;
        num = num / 1000;

        int y = num % 1000;
        num = num / 1000;

        int z = num % 1000;
        num = num / 1000;

        if (num > 0) {
            Print1(num, ss); ss << "Billion ";
        }

        if (z > 0) {
            Print3(z, ss); ss << "Million ";
        }

        if (y > 0) {
            Print3(y, ss); ss << "Thousand ";
        }

        if (x > 0) {
            Print3(x, ss);
        }
        auto s = ss.str();
        s.resize(s.size() - 1);
        return s;
    }
};
8400