(SW)Array1 - 최빈수 구하기

광어회깍뚝썰기·2021년 8월 9일
0

swea-intermediate

목록 보기
32/51

복사하여 sort를 한 리스트를 set처리(중복제거)하여 해결했다.

for tc in range(1,int(input())+1):
    t=int(input())
    arr=list(map(int, input().split()))
    chk=set(sorted(arr))
    
    maxx=0
    res=0
    for i in chk:
        if arr.count(i)>=maxx:
            maxx=arr.count(i)
            res=i
    
    print(f'#{t} {res}')

0개의 댓글

관련 채용 정보