Published:
Updated:


Solution

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]))


Reference

Leave a comment