SWEA

[SWEA] 1204. [S/W 문제해결 기본] 1일차 - 최빈수 구하기 (Python)

가은(JANE) 2024. 11. 12. 15:47

#Problem

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

 

#Think

  • cnt = [0] * 101이거면 [0,0,0,0,0,0 ... 0,0,0,0] 이런식으로 이용할 수 있다.

#Code

T = int(input())

for test_case in range(1, T + 1):
    n = int(input())
    scores = list(map(int,input().split()))
    cnt=[0]*101
    for score in scores :
        cnt[score]+=1
    maxnum = max(cnt)
    for i in range(100,-1,-1):
        if maxnum == cnt[i]:
            hey = i
            break
    print(f"#{test_case} {hey}")