O(n^2) --> O(n) Both Approaches Easy Code
\n# O(n^2) Approach [TLE]\ncpp []\nclass Solution {\npublic:\n    string sortVowels(string s) {\n        vector<int> nums;\n        vector<char> nums1;\n\n     
\n# O(n^2) Approach [TLE]\n```cpp []\nclass Solution {\npublic:\n    string sortVowels(string s) {\n        vector<int> nums;\n        vector<char> nums1;\n\n        // Step 1: Collect the indices of vowels and store their characters\n        for (int i = 0; i < s.size(); i++) {\n            if (s[i] == \'a\' || s[i] == \'e\' || s[i] == \'i\' || s[i] == \'o\' || s[i] == \'u\' || \n                s[i] == \'A\' || s[i] == \'E\' || s[i] == \'I\' || s[i] == \'O\' || s[i] == \'U\') {\n                nums.push_back(i);\n                nums1.push_back(s[i]);\n            }\n        }\n\n        // Step 2: Sort the vowels based on their ASCII values\n        sort(nums1.begin(), nums1.end());\n\n        // Step 3: Replace the vowels in the original string with the sorted ones\n        int j = 0;\n        for (int i = 0; i < s.size(); i++) {\n            if (find(nums.begin(), nums.end(), i) != nums.end()) {\n                s[i] = nums1[j++];\n            }\n        }\n\n        return s;\n    }\n};\n\n```\n# O(n) Approach [Accepted]\n```cpp []\nclass Solution {\npublic:\n    string sortVowels(string s) {\n        vector<int> nums;\n        vector<char> nums1;\n\n        // Step 1: Collect the indices of vowels and store their characters\n        for (int i = 0; i < s.size(); i++) {\n            if (s[i] == \'a\' || s[i] == \'e\' || s[i] == \'i\' || s[i] == \'o\' || s[i] == \'u\' || \n                s[i] == \'A\' || s[i] == \'E\' || s[i] == \'I\' || s[i] == \'O\' || s[i] == \'U\') {\n                nums.push_back(i);\n                nums1.push_back(s[i]);\n            }\n        }\n\n        // Step 2: Sort the vowels based on their ASCII values\n        sort(nums1.begin(), nums1.end());\n\n        // Step 3: Replace the vowels in the original string with the sorted ones\n        for (int i = 0; i < nums.size(); i++) {\n            s[nums[i]] = nums1[i];\n        }\n\n        return s;\n    }\n};\n\n```
['C++']