题目
按题意实现就可
class Solution {
public String sortString(String s) {
char[] arr = s.toCharArray();
int[] count = new int[26];
for(int chr:arr){
count[chr-'a']++;
}
String s1 = "";
int index = s.length();
while(index>0){
for(int i=0;i<26;i++){
if(count[i]>0){
s1 += (char)('a'+i);
count[i]--;
index--;
}
}
for(int j=25;j>=0;j--){
if(count[j]>0){
s1 += (char)('a'+j);
count[j]--;
index--;
}
}
}
return s1;
}
}