🚩 Coding Test/SWEA

[SWEA][S/W 문제해결 기본][Python] 1204 최빈수 구하기

zo0oz 2024. 5. 13. 22:45
728x90

[문제]

https://swexpertacademy.com/main/talk/solvingClub/problemView.do?solveclubId=AV6kld8aisgDFASb&contestProbId=AV13zo1KAAACFAYh&probBoxId=AV-HZfeqN3ADFASP&type=PROBLEM&problemBoxTitle=%5BD2%7ED3+%EB%AC%B8%EC%A0%9C%ED%92%80%EC%9D%B4%5D+%EA%B8%B0%EC%B4%88+%EB%8B%A4%EC%A7%80%EA%B8%B0+Part3&problemBoxCnt=14

 

SW Expert Academy

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

swexpertacademy.com

 

 

[코드]

T = int(input())
for t in range(1,T+1):
    tc = int(input())
    score = list(map(int,input().split()))

    cnt = [0] * 101
    for s in score:
        cnt[s] += 1

    #최빈수가 여러 개일 경우, 가장 큰 점수 출력
    res,idx = cnt[1], 1
    for i in range(2,101):
        if cnt[i] >= res:
            res = cnt[i]
            idx = i

    print("#"+str(t),idx)
반응형