from collections import defaultdict
import sys
sys.stdin = open("input.txt", "r")
T = int(input())
# 여러개의 테스트 케이스가 주어지므로, 각각을 처리합니다.
for test_case in range(1, T + 1):
test_num = int(input())
scores = list(map(int, input().split()))
scoresSet = set(scores)
scoreMap = defaultdict(int)
mfs, mfs_cnt = scores[0], 1
for item in scoresSet:
if mfs_cnt < scores.count(item):
mfs = item
mfs_cnt = scores.count(item)
print("#" + str(test_case) + " " + str(mfs))
쭉 나와있는 값들의 최빈수를 구하는 아주 간단한 문제였다.
Set으로 바꾼 뒤 순회하면서 업데이트 해주는 방식으로 간단하게 풀렸다.