Algorithm/프로그래머스

[프로그래머스] H-Index - 파이썬

potato_pizza 2024. 6. 19. 11:54
728x90

H-Index

https://school.programmers.co.kr/learn/courses/30/lessons/42747

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

 

문제

코드

  • citations 리스트를 내림차순으로 정렬
  • 루프를 돌면서 현재 인용횟수(i)가 현재의 h_index보다 크거나 같으면 h_index 값을 +1
def solution(citations):
    citations.sort(reverse=True)
    h_index = 0

    for i in citations:
        if i > h_index:
            h_index += 1

    return h_index
728x90
반응형