🥇 C++ | PYTHON | JAVA  ||  EXPLAINED  ||  ; ]
UPVOTE IF HELPFuuL\n\n# Approach\nThe strategy involves initially detecting the vowels in the input string s and recording both the vowels and their respective 
**UPVOTE IF HELPFuuL**\n\n# Approach\nThe strategy involves initially detecting the vowels in the input string ```s``` and recording both the vowels and their respective positions in two distinct vectors, namely ```vowels_list``` and ```vowel_positions```. Subsequently, the code arranges the vowels in ascending order by sorting the ```vowels_list``` vector. Following this, a new string named ```resultString``` is generated, initially mirroring the content of the input string \'s\'.\n\nUltimately, the code substitutes the characters at the positions stored in the ```vowel_positions``` vector with the sorted vowels from the ```vowels_list``` vector. The resulting modified string, now containing the vowels in sorted order, is returned as the output of the function.\n\n# Complexity\n- Time complexity: O( N * log N )\n\n- Space complexity: O( N )\n\n# Python Code\n```\nclass Solution:\n    def sortVowels(self, input_str: str) -> str:\n        vowels_list = []\n        vowel_positions = []\n        \n        for index, char in enumerate(input_str):\n            if char.lower() in {\'a\', \'e\', \'i\', \'o\', \'u\'}:\n                vowels_list.append(char)\n                vowel_positions.append(index)\n        \n        vowels_list.sort()\n        result_list = list(input_str)\n        \n        for position, vowel in zip(vowel_positions, vowels_list):\n            result_list[position] = vowel\n        \n        return \'\'.join(result_list)\n```\n\n\n# C++ Code\n```\nclass Solution {\npublic:\n    string sortVowels(string inputString) {\n        int sizeOfString = inputString.size();\n        vector<char> vowels;\n        vector<int> vowelPositions;\n        for(int i = 0; i < sizeOfString; i++) {\n            if(inputString[i] == \'a\' || inputString[i] == \'e\' || inputString[i] == \'i\' || inputString[i] ==\'o\' || inputString[i] == \'u\' || inputString[i] == \'A\' || inputString[i] == \'E\' || inputString[i] == \'O\' || inputString[i] == \'I\' || inputString[i] == \'U\') {for vowel\n                vowels.push_back(inputString[i]);\n                vowelPositions.push_back(i); \n            }\n        }\n        sort(vowels.begin(), vowels.end());\n        string resultString = inputString;\n        for(int i = 0; i < vowelPositions.size(); i++) {\n            resultString[vowelPositions[i]] = vowels[i];\n        }\n        return resultString;\n    }\n};\n```\n\n# JAVA Code\n```\nclass Solution {\n    public String sortVowels(String inputString) {\n        int length = inputString.length();\n        ArrayList<Character> vowelsList = new ArrayList<>();\n        ArrayList<Integer> vowelPositions = new ArrayList<>();\n        \n        for (int i = 0; i < length; i++) {\n            char currentChar = inputString.charAt(i);\n            if (currentChar == \'a\' || currentChar == \'e\' || currentChar == \'i\' || \n                currentChar == \'o\' || currentChar == \'u\' || currentChar == \'A\' || \n                currentChar == \'E\' || currentChar == \'I\' || currentChar == \'O\' || \n                currentChar == \'U\') {\n                vowelsList.add(currentChar);\n                vowelPositions.add(i);\n            }\n        }\n        \n        Collections.sort(vowelsList);\n        \n        char[] resultArray = inputString.toCharArray();\n        for (int i = 0; i < vowelPositions.size(); i++) {\n            resultArray[vowelPositions.get(i)] = vowelsList.get(i);\n        }\n        \n        return new String(resultArray);\n    }\n}\n\n```
['Python', 'C++', 'Java', 'Python3']