<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:
    string numberToWords(int num) {
        if (num == 0)
            return "Zero";

        string result;

        // Process billions
        int billion = num / 1000000000;
        if (billion) {
            result += threeDigitsToWords(billion) + " Billion";
            num %= 1000000000;
        }

        // Process millions
        int million = num / 1000000;
        if (million) {
            if (!result.empty()) result += " ";
            result += threeDigitsToWords(million) + " Million";
            num %= 1000000;
        }

        // Process thousands
        int thousand = num / 1000;
        if (thousand) {
            if (!result.empty()) result += " ";
            result += threeDigitsToWords(thousand) + " Thousand";
            num %= 1000;
        }

        // Process the remainder
        if (num) {
            if (!result.empty()) result += " ";
            result += threeDigitsToWords(num);
        }

        return result;
    }

private:
    vector<string> below_20 = {"", "One", "Two", "Three", "Four", "Five", "Six",
                               "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve",
                               "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen",
                               "Eighteen", "Nineteen"};
    vector<string> tens = {"", "", "Twenty", "Thirty", "Forty", "Fifty", "Sixty",
                           "Seventy", "Eighty", "Ninety"};

    // Helper function to convert numbers less than 1000
    string threeDigitsToWords(int num) {
        string result;

        // Process hundreds place
        int hundred = num / 100;
        if (hundred) {
            result += below_20[hundred] + " Hundred";
            num %= 100;
        }

        // Process tens and ones place
        if (num) {
            if (!result.empty()) result += " ";
            if (num < 20) {
                result += below_20[num];
            } else {
                result += tens[num / 10];
                if (num % 10) {
                    result += " " + below_20[num % 10];
                }
            }
        }

        return result;
    }
};

11600