본문 바로가기

Algorithm/SWEA

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

https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=2&contestProbId=AV13zo1KAAACFAYh&categoryId=AV13zo1KAAACFAYh&categoryType=CODE&problemTitle=&orderBy=FIRST_REG_DATETIME&selectCodeLang=PYTHON&select-1=2&pageSize=10&pageIndex=3 

 

SW Expert Academy

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

swexpertacademy.com

import sys
sys.stdin = open("input.txt","r")

T = int(input())

for test_case in range(1,T+1):
    test_num = int(input())
    case = list(map(int, input().split()))
    
    grade_count = [0]*101 #인덱스가 점수
    max = 0
    score = 0

    for i in range(len(case)):
        grade_count[case[i]] += 1

    for k in range(len(grade_count)):
        if (max <=grade_count[k]):
            max = grade_count[k]
            score = k

    print("#"+str(test_case)+ " "+ str(score))