<p>Given a <strong>0-indexed</strong> string <code>s</code>, <strong>permute</strong> <code>s</code> to get a new string <code>t</code> such that:</p>

<ul>
	<li>All consonants remain in their original places. More formally, if there is an index <code>i</code> with <code>0 &lt;= i &lt; s.length</code> such that <code>s[i]</code> is a consonant, then <code>t[i] = s[i]</code>.</li>
	<li>The vowels must be sorted in the <strong>nondecreasing</strong> order of their <strong>ASCII</strong> values. More formally, for pairs of indices <code>i</code>, <code>j</code> with <code>0 &lt;= i &lt; j &lt; s.length</code> such that <code>s[i]</code> and <code>s[j]</code> are vowels, then <code>t[i]</code> must not have a higher ASCII value than <code>t[j]</code>.</li>
</ul>

<p>Return <em>the resulting string</em>.</p>

<p>The vowels are <code>&#39;a&#39;</code>, <code>&#39;e&#39;</code>, <code>&#39;i&#39;</code>, <code>&#39;o&#39;</code>, and <code>&#39;u&#39;</code>, and they can appear in lowercase or uppercase. Consonants comprise all letters that are not vowels.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;lEetcOde&quot;
<strong>Output:</strong> &quot;lEOtcede&quot;
<strong>Explanation:</strong> &#39;E&#39;, &#39;O&#39;, and &#39;e&#39; are the vowels in s; &#39;l&#39;, &#39;t&#39;, &#39;c&#39;, and &#39;d&#39; are all consonants. The vowels are sorted according to their ASCII values, and the consonants remain in the same places.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;lYmpH&quot;
<strong>Output:</strong> &quot;lYmpH&quot;
<strong>Explanation:</strong> There are no vowels in s (all characters in s are consonants), so we return &quot;lYmpH&quot;.
</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</code> consists only of letters of the&nbsp;English alphabet&nbsp;in <strong>uppercase and lowercase</strong>.</li>
</ul>

class Solution {
public:
    bool isVowel(char s){
        return s=='A' || s=='E' || s=='I' || s=='O' || s=='U' || s=='a' || s=='e' || s=='i' || s=='o' ||s=='u';
    }

    int find(vector<int>& a){
        for(int i=0;i<a.size();i++){
            if(a[i]>0){
                return i;
            }
        }

        return -1;
    }
    string sortVowels(string s) {
        vector<int> f(10);

        for(int i=0;i<s.length();i++){
            if(s[i]=='A'){
                f[0]++;
            }
            if(s[i]=='E'){
                f[1]++;
            }
            if(s[i]=='I'){
                f[2]++;
            }
            if(s[i]=='O'){
                f[3]++;
            }
            if(s[i]=='U'){
                f[4]++;
            }
            if(s[i]=='a'){
                f[5]++;
            }
            if(s[i]=='e'){
                f[6]++;
            }
            if(s[i]=='i'){
                f[7]++;
            }
            if(s[i]=='o'){
                f[8]++;
            }
            if(s[i]=='u'){
                f[9]++;
            }
        }

        int rowIndex = -1;

        for(int i=0;i<s.length();i++){
            if(isVowel(s[i])){
                 int rowIndex = find(f);
                 if(rowIndex == 0){
                     s[i] = 'A';
                 }
                 if(rowIndex == 1){
                    s[i] = 'E';
                 }
                 if(rowIndex == 2){
                    s[i] = 'I';
                 }   
                 if(rowIndex == 3){
                    s[i] = 'O';
                 }
                 if(rowIndex == 4){
                    s[i] = 'U';
                 }
                 if(rowIndex == 5){
                    s[i] = 'a';
                 }
                 if(rowIndex == 6){
                    s[i] = 'e';
                 }
                 if(rowIndex == 7){
                    s[i] = 'i';
                 }
                 if(rowIndex == 8){
                    s[i] = 'o';
                 }
                 if(rowIndex == 9){
                    s[i] = 'u';
                 }
                 
                 
                 f[rowIndex]--;
            }
        }

        return s;
    }
};
13500