Video Solution | Explanation With Drawings | In Depth | Java | C++
Intuition, approach, and complexity discussed in detail in video solution\nhttps://youtu.be/PBuGJWtu_wI\n# Code\nJava\n\nclass Solution {\n    private boolean i
# Intuition, approach, and complexity discussed in detail in video solution\nhttps://youtu.be/PBuGJWtu_wI\n# Code\nJava\n```\nclass Solution {\n    private boolean isVowel(char c){\n        return c == \'a\' || c == \'e\' || c == \'i\' || c == \'o\' || c == \'u\' || c == \'A\' || \nc == \'E\' || c == \'I\' || c == \'O\' || c == \'U\';\n    }\n    public String sortVowels(String str) {\n        char s[] = str.toCharArray();\n        int vowelFreq[] = new int[256];\n        for(var chr : s){\n           if(isVowel(chr)) \n            vowelFreq[chr]++;\n        }\n        int freqIndx = 0;\n        while(freqIndx < 256 && vowelFreq[freqIndx] == 0)freqIndx++;\n        for(int strIndx = 0; strIndx < s.length; strIndx++){\n            if(isVowel(s[strIndx])){\n                s[strIndx] = (char)(freqIndx);\n                if(--vowelFreq[freqIndx] == 0)freqIndx++;\n            }\n            while(freqIndx < 256 && vowelFreq[freqIndx] == 0)freqIndx++;\n        }\n        return new String(s);\n    }\n}\n```\nC++\n```\nclass Solution {\nprivate: \n    bool isVowel(char c){\n        return c == \'a\' || c == \'e\' || c == \'i\' || c == \'o\' || c == \'u\' || c == \'A\' || \nc == \'E\' || c == \'I\' || c == \'O\' || c == \'U\';\n    }\npublic:\n    string sortVowels(string s) {\n        vector<int> vowelFreq(256);\n        for(auto chr : s){\n           if(isVowel(chr)) \n            vowelFreq[chr]++;\n        }\n        int freqIndx = 0;\n        while(freqIndx < 256 && !vowelFreq[freqIndx])freqIndx++;\n        for(int strIndx = 0; strIndx < s.size(); strIndx++){\n            if(isVowel(s[strIndx])){\n                s[strIndx] = (char)(freqIndx);\n                if(--vowelFreq[freqIndx] == 0)freqIndx++;\n            }\n            while(freqIndx < 256 && !vowelFreq[freqIndx])freqIndx++;\n        }\n        return s;\n    }\n};\n```
['C++', 'Java']