본문 바로가기

알고리즘

[정렬] 프로그래머스 - H-index

python

def solution(citations):
    answer = 0
    
    citations.sort() 
    
    cnt = 0
    length = len(citations)
    
    for a in citations:
        if a <= length - cnt :
            answer = a     
        if a >length -cnt:
            if answer < length -cnt:
                answer = length -cnt
        cnt += 1
    
    return answer