프로그래머스 정렬 h-index 질문이요
조회수 445회
https://programmers.co.kr/learn/courses/30/lessons/42747 프로그래머스 h-index 문제인데요. 테스트 케이스에서 16번 케이스만 통과를 못 하네요. 제가 고려하지 못한 경우가 있는 건가요?
def solution(citations):
n = len(citations)
for h in range(n,0,-1):
cnt = 0
for citation in citations:
if citation >= h:
cnt = cnt + 1
if cnt >= h:
answer = h
return answer
총 논문의 수를 n으로 놓고 n부터 1씩 감소하면서 h값이 맞는지 cnt변수로 확인했고 n부터 확인했으니까 h값이 맞으면 그게 가장 큰 h 값이라고 생각했는데여
댓글 입력