Easy Approach 🔥 🔥 || Java || ☑️ Beginner's
Intuition\nThe solution operates by identifying vowels in the input string, sorting them, and then replacing the original vowels with the sorted ones. The use o
# Intuition\nThe solution operates by identifying vowels in the input string, sorting them, and then replacing the original vowels with the sorted ones. The use of the is_Vowel function simplifies the identification process.\n\n# Approach\nThe provided solution consists of two functions: is_Vowel and sortVowels. Let\'s break down the approach used in each function.\n\nis_Vowel Function:\nThis function checks whether a given character is a vowel. It returns true if the character is a vowel (\'a\', \'e\', \'i\', \'o\', \'u\' or their uppercase counterparts), and false otherwise.\nThis function takes a string as input and sorts its vowels in lexicographical order. It uses the is_Vowel function to identify vowels and then sorts them using the sort function .\n\n# Complexity\n* Time complexity: O(n + k * log(k)), where k is the number of vowels.\n* Space complexity: O(k) where k is the number of vowels.\n\n# Code\n```\nclass Solution {\n    public String sortVowels(String s) {\n        StringBuilder sb = new StringBuilder();\n        ArrayList<Character> list = new ArrayList<>();\n\n        for(int i = 0 ; i < s.length() ; i++){\n            char ch = s.charAt(i);\n            if(ch == \'a\' || ch == \'e\' || ch == \'i\' || ch == \'o\' || ch == \'u\' || ch == \'A\' || ch == \'E\' || ch == \'I\' || ch == \'O\' || ch==\'U\'){\n                list.add(ch);\n            }\n        }\n        Collections.sort(list);\n        int index = 0;\n\n        for(int j = 0 ; j < s.length() ; j++){\n            char ch = s.charAt(j);\n            if(ch == \'a\' || ch == \'e\' || ch == \'i\' || ch == \'o\' || ch == \'u\' || ch == \'A\' || ch == \'E\' || ch == \'I\' || ch == \'O\' || ch==\'U\'){\n                sb.append(list.get(index++));\n            }\n            else{\n                sb.append(ch);\n            }\n            \n        }\n        return sb.toString();\n    }\n}\n```
['String', 'Sorting', 'Java']