: 찾는 키가 존재한다면 찾는 키의 VALUE를 반환하고 없다면 기본 값을 반환하는 메서드
size_cnt에 t값을 가져오고 없다면 0을 가져옴.
Map<Integer, Integer> size_cnt=new HashMap<Integer, Integer>();
for(int t: tan) {
size_cnt.put(t,size_cnt.getOrDefault(t, 0) + 1);
}
System.out.println("정렬전 : "+size_cnt);
O(1)
🌟 리스트에서 특정 원소의 개수를 map에 저장하고 싶을때 collections.frequency (시간복잡도 : O(N^2) 대신 사용 가능!