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

       // map<string, in> digit(
          //  {"z",0}; //unique-->z
          // {"one",1};
          // {"w",2}; // unique: w
          //  {"three",3};
          //  {"u",4}; // unique:u
          //  {"five",5};
          //  {"x",6}; //unique:x
          //  {"seven",7};
          //  {"g",8}; //unique g
          //  {"nine",9};
        //});

        // con unique --> conti i pari
        // dei rimanenti: con f--> 4+5; h-->3+8; s-->7+6
        // rimangono 9 --> da i ;e 1---> da n: 7 e 9
        map<char,int> freq;

        for (auto c:s){
            ++freq[c];
        }

        vector<int> num(10,0);
        num[0]=freq['z'];
        num[2]=freq['w']; 
        num[4]=freq['u'];
        num[5]=freq['f']-num[4];
        num[6]=freq['x'];
        num[7]=freq['s']-num[6];
        num[8]=freq['g'];
        num[3]=freq['h']-num[8];
        num[9]=freq['i']-num[5]-num[6]-num[8];
        num[1]=freq['n']-2*num[9]-num[7]; 

        string v;

        for (size_t i=0;i<num.size();i++){
            int k=num[i];
            while (k>0){
                v.append(to_string(i));
                k--;
            }
        }
        return v;
    }
};


14000