본문 바로가기
Programming/Python

[프로그래머스] H-Index

by 왕밤빵도라에몽 2025. 4. 14.
728x90

기본 아이디어

  • 역순 정렬해서 하나씩 카운트
def solution(citations):
    sorted_ct = sorted(citations, reverse=True)
    max_h = 0
    for i in range(len(citations) + 1):
        cnt = 0
        for c in sorted_ct:
            if c >= i:
                cnt += 1
            else:
                break
        if cnt >= i:
            max_h = i
    return max_h
  • 문제의 조건 자체가 되게 헷갈렸음. 논문수, 인용수 모두 h여야하는 것이 아닌 h이상인지를 체크하는 것
728x90

'Programming > Python' 카테고리의 다른 글

[LeetCode] 1. Two Sum  (0) 2025.05.04
[프로그래머스] 의상  (0) 2025.04.30
[프로그래머스] 네트워크  (0) 2025.04.13
[프로그래머스] 모음사전  (0) 2025.04.12
[프로그래머스] 전화번호 목록  (0) 2025.04.12