티스토리 뷰
입력받은 리스트의 길이 citations부터 0까지 반복문을 실행한다.
citations의 요소 number와 h를 비교해 number가 h 이상일 때 count를 1 증가시킨다.
만약 count가 h 이상이면 h를 반환한다. 반복문이 모두 종료되어도 반환되는 값이 없으면 0을 반환한다.
문제풀이
def solution(citations):
for h in range(len(citations), 0, -1):
count = 0
for number in citations:
if number >= h:
count += 1
if count >= h:
return h
return 0'문제 풀이 > Programmers' 카테고리의 다른 글
| [python3][level 2] 프린터 (0) | 2019.04.07 |
|---|---|
| [python3][level 2] 쇠막대기 (0) | 2019.04.05 |
| [python3][level 3] 베스트앨범 (0) | 2019.04.04 |
| [python3][level 3] 타일 장식물 (0) | 2019.03.29 |
| [python3][level 2] 위장 (0) | 2019.03.28 |
댓글