C++ || frequency count and bucket sort || TC O(n), SC O(1) || fast
Approach 1: frequency count and bucket sort (12ms)\nNot quite sure if we should call this bucket sort, but this is just looking at the relevant frequency bucket
# Approach 1: frequency count and bucket sort ([12ms](https://leetcode.com/submissions/detail/1098221332/))\nNot quite sure if we should call this bucket sort, but this is just looking at the relevant frequency buckets in order. It\'s kinda awesome what code the compiler generates for the ```isVowel``` function: https://godbolt.org/z/6YsPq1ebc\n\n```cpp\n    static bool isVowel(char ch) {\n        return\n            ch == \'A\' || ch == \'E\' || ch == \'I\' || ch == \'O\' || ch == \'U\' ||\n            ch == \'a\' || ch == \'e\' || ch == \'i\' || ch == \'o\' || ch == \'u\';\n    }\n\n    static string sortVowels(string s) {\n        array<int, 128> cnt = {};\n        for (char ch : s) ++cnt[ch];\n\n        int w = 0;\n        for (char ch : "AEIOUaeiou")\n            while (cnt[ch]--) {\n                while (!isVowel(s[w])) ++w;\n                s[w++] = ch;\n            }\n        \n        return s;\n    }\n```\n\n**Complexity Analysis**\nLet $$n$$ be the length of the input string then the\n\n* Time complexity is $$O(n)$$ as we only need to scan the input twice and the\n\n* Space comlexity is $$O(1)$$ as we only keep a fixed size frequency count array and some loop variables.\n\n_As always: Feedback, questions, and comments are welcome. Leaving an up-vote sparks joy! :)_\n\n**p.s. Join us on the [LeetCode The Hard Way Discord Server](https://discord.gg/hFUyVyWy2E)!**\n
['C', 'Bucket Sort']