중괄호를 모두 없애고 숫자, 쉼표만 남기기 위해 replace를 사용했다.
튜플의 맨 앞은 모든 배열에 등장하고, 그 다음은 한번 적게 , 튜플의 맨 마지막은 한번만 등장하므로
튜플의 숫자를 key 값으로 하고, 등장횟수를 value로 하여 map에 저장하고
내림차순으로 정렬하면 해결될것이라고 생각했다.
		List<Integer> keySetList = new ArrayList<>(map.keySet());
		
		// 오름차순
		System.out.println("------value 오름차순------");
		Collections.sort(keySetList, (o1, o2) -> (map.get(o1).compareTo(map.get(o2))));
		
		for(Integer key : keySetList) {
			System.out.println("key : " + key + " / " + "value : " + map.get(key));
		}
		
		System.out.println();
		
		// 내림차순
		System.out.println("------value 내림차순------");
		Collections.sort(keySetList, (o1, o2) -> (map.get(o2).compareTo(map.get(o1))));
		for(Integer key : keySetList) {
			System.out.println("key : " + key + " / " + "value : " + map.get(key));
		}
import java.util.*;
class Solution {
    public int[] solution(String s) {
        
        Map<String,Integer> map = new HashMap();
        s = s.replace("{","");
        s = s.replace("}","");
        
        String [] arr = s.split(",");
        
        for(int i=0; i<arr.length; i++){
           int count = map.containsKey(arr[i]) ? map.get(arr[i])+1 : 1; 
           map.put(arr[i],count);    
        }
        
        List<String> keySetList = new ArrayList<>(map.keySet());
        Collections.sort(keySetList, (o1, o2) -> (map.get(o2).compareTo(map.get(o1))));
	int[] answer = new int[map.size()];
        int i=0;
        for(String key : keySetList) {
            answer[i] = Integer.parseInt(key);
            i++;
	}
        
        return answer;
    }
}