2785. Sort Vowels in a String
IntuitionApproach
select the vowels
sort the vowls
insert the vowl at write place
Complexity
Time complexity: O(N)

Space complexity: O(N)
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->The task is to sort the vowels (both uppercase and lowercase) in a string, leaving all non-vowel characters in their original positions.

# Approach
<!-- Describe your approach to solving the problem. -->
1. select the vowels
2. sort the vowls
3. insert the vowl at write place

# Complexity
- Time complexity: O(N)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(N)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    string sortVowels(string s) {

        vector<int>lower(26,0);
        vector<int>upper(26,0);

        //store lower and  uppervpwels

        for(int i = 0; i<s.size(); i++){
            if(s[i]=='a' || s[i]=='e' || s[i]=='i' || s[i]=='o' || s[i]=='u'){
                lower[s[i]-'a']++;
                s[i]='#';
            }
            else if(s[i]=='A' || s[i]=='E' || s[i]=='I' || s[i]=='O' || s[i]=='U'){
            upper[s[i]-'A']++;
                s[i]='#';
            }
        }

        string vowel;
            // upper sort
        for(int i = 0; i<26; i++){

            char c = 'A'+i;

            while(upper[i]){
                vowel += c;
                upper[i]--;
            }
        }

             //lower sort
        for(int i = 0; i<26; i++){

            char c = 'a'+i;

            while(lower[i]){
                vowel += c;
                lower[i]--;
            }
        }

        int first =0, second=0;

        while(second<vowel.size()){
            if(s[first]=='#'){
                s[first]= vowel[second];
                second++;
            }
            first++;
        }

        return s;
    }
};
```
['C++']