Problem Solving
84. H-Index
굥깡
2023. 1. 15. 22:00
728x90
https://school.programmers.co.kr/learn/courses/30/lessons/42747
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
n개의 숫자 원소를 가진 배열을 입력받아 h 이상의 원소가 h개 이상일 때 h의 최댓값을 구하는 문제
def solution(citations):
citations = sorted(citations, reverse=True)
print(citations)
for i in range(len(citations)):
if i + 1 == citations[i]:
return citations[i]
if i + 1 > citations[i]:
return i
if len(citations) > 0 and citations[0] != 0:
return len(citations)
answer = 0
return answer
H-Index라는 말을 처음 들었다...
코드를 짜놓고도 9번 테스트 케이스를 계속 통과 못했는데 [10000, 9999, 9998, 9997, 9996]라는 반례가 있었다
정답은 5가 나와야 하지만 내 코드는 0이 나와서 그부분 수정했더니 통과