Code Signal: Intro=46/60
by 습관중독def electionsWinners(votes, k):
FINAL = 0
votes.sort()
if k==0 and votes[-1] != votes[-2]:
return 1
for i in range(len(votes)):
if votes[-i]+k > max(votes):
FINAL += 1
return FINAL
10/12 tests passed. Execution time limit exceeded on test 11: Program exceeded the execution time limit. Make sure that it completes execution in a few seconds for any possible input.
알고리즘 자체는 맞았는데 저런 메시지 나와서 포기.
sort 함수에서 시간 초과 요인 발생한 것으로 짐작.
'코드 파이트(Code Signal)' 카테고리의 다른 글
Code Signal: Intro=48/60 (0) | 2020.02.23 |
---|---|
Code Signal: Intro=47/60 (0) | 2020.02.23 |
Code Signal: Intro=45/60 (0) | 2020.02.23 |
Code Signal: Intro=44/60 (0) | 2020.02.23 |
Code Signal: Intro=43/60 (0) | 2020.02.23 |
블로그의 정보
습관을 애정한다
습관중독