<p>Given a string <code>s</code> containing an out-of-order English representation of digits <code>0-9</code>, return <em>the digits in <strong>ascending</strong> order</em>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre><strong>Input:</strong> s = "owoztneoer"
<strong>Output:</strong> "012"
</pre><p><strong class="example">Example 2:</strong></p>
<pre><strong>Input:</strong> s = "fviefuro"
<strong>Output:</strong> "45"
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= s.length &lt;= 10<sup>5</sup></code></li>
	<li><code>s[i]</code> is one of the characters <code>[&quot;e&quot;,&quot;g&quot;,&quot;f&quot;,&quot;i&quot;,&quot;h&quot;,&quot;o&quot;,&quot;n&quot;,&quot;s&quot;,&quot;r&quot;,&quot;u&quot;,&quot;t&quot;,&quot;w&quot;,&quot;v&quot;,&quot;x&quot;,&quot;z&quot;]</code>.</li>
	<li><code>s</code> is <strong>guaranteed</strong> to be valid.</li>
</ul>

class Solution {
public:
    string originalDigits(string s) {
        unordered_map<int, string> digit_to_word = {
            {0, "zero"}, // z
            {2, "two"},  // w
            {4, "four"}, // u
            {6, "six"},  // x
            {8, "eight"},// g
            {3, "three"},// h (!g)
            {5, "five"}, // f(!u)
            {7, "seven"},// s(!x)
            {9, "nine"},  // i
            {1, "one"}  // n
        };

        const vector<pair<int, char>> unique_letter = {
            {0, 'z'}, {2, 'w'}, {4, 'u'}, {6, 'x'},
            {8, 'g'}, {3, 'h'}, {5, 'f'}, {7, 's'},
            {9, 'i'}, {1, 'n'}
        };

        unordered_map<char, int> counter;
        for (auto &c : s) {
            ++counter[c];
        }

        vector<int> ans(10);
        int size = 0;
        for (const auto &[dig, let] : unique_letter) {
            if (counter.contains(let)) {
                ans[dig] += counter[let];
                size += ans[dig];
                for (auto &c : digit_to_word[dig]) {
                    counter[c] -= ans[dig];
                }
            }
        }

        string result(size, ' ');

        int ind = 0;
        for (int i = 0; i < 10; ++i) {
            for (int j = 0; j < ans[i]; ++j) {
                result[ind++] = char(i + '0');
            }
        }

        return result;
    }
};
11300