본문 바로가기

알고리즘/해커랭크

Birthday Cake Candles(python3)

문제

가장 긴 길이의 양초 개수를 출력

 

입력

4
3 2 1 3

출력

2

 

통과한 코드

from collections import Counter

def birthdayCakeCandles(ar):
    dcount = Counter(ar)
    return dcount[max(dcount.keys())]

 

리스트보다 딕셔너리가 빠름

 

'알고리즘 > 해커랭크' 카테고리의 다른 글

Kangaroo  (0) 2020.03.06
Apple and Orange  (0) 2020.03.06
Grading Students (python3)  (0) 2020.02.29
Loops (python3)  (0) 2020.02.27
Python If-Else Discussions  (0) 2020.02.27