<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>

constexpr int thousand = 1000;
constexpr int million = thousand * thousand;
constexpr int billion = million * thousand;

constexpr char* a[10] = {
    "", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"
};
constexpr char* b[10] = {
    "", "", "", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"
};
constexpr char* c[10] {
    "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"
};
class Solution {
    string underThousand(int num) {
        string s = "";
        if (num >= 100) {
            s += string(a[num/100]) + " Hundred";
            num = num % 100;
        }
        if (num >= 30) {
            if (!s.empty()) s += " ";
            s += b[num/10];
            num = num % 10;
        }
        if (num >= 20) {
            if (!s.empty()) s += " ";
            s += "Twenty";
            num = num % 10;
        }
        if (num >= 10) {
            if (!s.empty()) s += " ";
            s += c[num - 10];
        } else if (num == 0) return s;
        else {
            if (!s.empty()) s += " ";
            s += a[num];
        }
        return s;
    }
public:
    string numberToWords(int num) {
        if (num == 0) return "Zero";
        string ans = "";
        if (num >= billion) {
            auto b = underThousand(num / billion);
            ans += b + " Billion";
            num = num % billion;
        }
        if (num >= million) {
            auto m = underThousand(num / million);
            if (!ans.empty()) ans += " ";
            ans += m + " Million";
            num = num % million;
        }
        if (num >= thousand) {
            auto k = underThousand(num / thousand);
            if (!ans.empty()) ans += " ";
            ans += k + " Thousand";
            num = num % thousand;
        }
        if (num == 0) return ans;
        auto w = underThousand(num);
        if (!ans.empty()) ans += " ";
        ans += w;
        return ans;
    }
};
9000