import java.util.*;
class Solution {
public List<Integer> solution(String s) {
HashMap<Integer, Integer> map = new HashMap<>();
String[] numbers = s.replaceAll("\\{","").replaceAll("\\}", "").split(",");
for(String x: numbers){
int num = Integer.parseInt(x.trim());
map.put(num, map.getOrDefault(num, 0)+1);
}
List<Integer> keys = new ArrayList<>(map.keySet());
Collections.sort(keys, (v1, v2) -> (map.get(v2).compareTo(map.get(v1))));
ArrayList<Integer> list = new ArrayList<>();
for(Integer key : keys){
list.add(key);
}
return list;
}
}