题目
1.如何以char类型便利字符串
2.自定义优先队列解决
class Solution {public String sortVowels(String s) {Map<Character,Integer> m= new HashMap<>();m.put('a',1);m.put('e',1);m.put('i',1);m.put('o',1);m.put('u',1);m.put('A',1);m.put('E',1);m.put('I',1);m.put('O',1);m.put('U',1);PriorityQueue<Character> pq= new PriorityQueue<>((a,b)->a-b);for(Character c : s.toCharArray())if(m.containsKey(c)) pq.offer(c);StringBuilder sb= new StringBuilder();for(Character c : s.toCharArray()){if(m.containsKey(c)) sb.append(pq.poll());else sb.append(c);}return sb.toString();}
}