문제
나열된 숫자 중 제일 많이 나온 숫자를 출력
제일 많이 나온 숫자가 동일할 경우 그 중 작은 숫자를 출력
입력 예시
6
1 4 4 5 3
출력
4
제출한 코드
from collections import Counter
def migratoryBirds(arr):
count = Counter(arr)
cmax = max(count.values())
res = max(count.keys())
for key, val in count.items():
if val==cmax and key<res:
res=key
return res
'알고리즘 > 해커랭크' 카테고리의 다른 글
Bon Appétit (0) | 2020.03.08 |
---|---|
Day of Programer (0) | 2020.03.08 |
Divisible Sum Pairs (0) | 2020.03.08 |
Birthday Chocolate (0) | 2020.03.08 |
Breaking the Records (0) | 2020.03.07 |