Published:
Updated:


SolutionPermalink

from typing import List


def solution(citations: List[int]) -> int:
    N = len(citations)
    # h의 μ΅œλŒ“κ°’
    answer = 0

    citations.sort()

    for i, citation in enumerate(citations):
        #  μ €μžμ˜ H-μ§€μˆ˜λŠ” κ·Έλ“€μ˜ N편의 λ…Όλ¬Έ 쀑 h편이 적어도 h번 μΈμš©λ˜μ—ˆκ³ ,
        #  λ‚˜λ¨Έμ§€ (N βˆ’ h)편의 논문이 hλ²ˆμ„ μ΄ˆκ³Όν•˜μ§€ μ•Šκ²Œ μΈμš©λ˜μ—ˆμ„ λ•Œμ˜ h 값을 가짐
        if citation >= N - i:
            answer = N - i
            break

    return answer


print(solution([3, 0, 6, 1, 5]))


ReferencePermalink

Leave a comment