<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 getSingle(int num) {
        switch (num) {
            case 1:
                return "One";
            case 2:
                return "Two";
            case 3: 
                return "Three";
            case 4:
                return "Four";
            case 5:
                return "Five";
            case 6:
                return "Six";
            case 7:
                return "Seven";
            case 8:
                return "Eight";
            case 9:
                return "Nine";
            default: 
                return "zero";
        }
    }
    
    string getSpecial(int num) {
        switch (num) {
            case 10:
                return "Ten";
            case 11:
                return "Eleven";
            case 12:
                return "Twelve";
            case 13:
                return "Thirteen";
            case 14:
                return "Fourteen";
            case 15:
                return "Fifteen";
            case 16:
                return "Sixteen";
            case 17:
                return "Seventeen";
            case 18:
                return "Eighteen";
            case 19:
                return "Nineteen";
            default:
                return "zero";
        }
    }
    
    string getTwoD(int num) {
        switch (num) {
            case 2:
                return "Twenty";
            case 3:
                return "Thirty";
            case 4:
                return "Forty";
            case 5:
                return "Fifty";
            case 6:
                return "Sixty";
            case 7:
                return "Seventy";
            case 8:
                return "Eighty";
            case 9:
                return "Ninety";
            default:
                return "zero";
        }
    }
    
    string processTriple(int num) {
        // expected a 3 digit number abc
        string res = "";
        int firstD = num / 100;
        int lastTwo = num % 100;
        int secondD = lastTwo / 10;
        int lastD = lastTwo % 10;

        if (lastTwo == 0){
        } else if (lastTwo < 10) {
            res += getSingle(lastD);
        } else if (lastTwo < 20) {
            res += getSpecial(lastTwo);
        } else {
            res += getTwoD(secondD);
            if (lastD > 0) {
                res += " " + getSingle(lastD);
            }
        }
        
        if (firstD > 0) {
            string head = getSingle(firstD) + " Hundred";
            if (lastTwo != 0) {
                res = head + " " + res;
            } else {
                res = head;
            }
        }

        return res;
    }
    
    string getModifier(int num) {
        switch (num) {
            case 1:
                return "Thousand";
            case 2:
                return "Million";
            case 3:
                return "Billion";
            case 4:
                return "Trillion";
            case 5:
                return "Quadrillion";
            case 6:
                return "Quintillion";
            case 7:
                return "Sextillion";
            default:
                return "";
                
        }
    }
    
    string numberToWords(int num) {
        if (num == 0) 
            return "Zero";
        string res = "";
        int count = 0;
        while (num > 0) {
            int lastThree = num % 1000;
            if (lastThree > 0) {
                string curr = processTriple(lastThree);
                if (count > 0) {
                    curr += " " + getModifier(count);
                    if (res != "")
                        curr += " ";
                }
                res = curr + res;
            }
            count++;
            num /= 1000;
        }
        return res;
    }
};
9100