题解 | #字符统计#
字符统计
http://www.nowcoder.com/practice/c1f9561de1e240099bdb904765da9ad0
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
String s = in.next();
Map<Character,Integer> hs = new TreeMap<>();
for(int i = 0; i<s.length(); i++){
if(!hs.containsKey(s.charAt(i))){
hs.put(s.charAt(i),1);
}else{
hs.put(s.charAt(i),hs.get(s.charAt(i))+1);
}
}
int max = 0;
for(int a : hs.values()){
max = Math.max(a,max);
}
while(max>0){
for(char ch : hs.keySet()){
if(hs.get(ch)==max){
System.out.print(ch);
}
}
max--;
}
}
}
}