본문 바로가기
알고리즘/프로그래머스

[프로그래머스] H-Index(Java)

by hxxyeoniii 2025. 2. 27.

링크 : https://school.programmers.co.kr/learn/courses/30/lessons/42747#qna

 

프로그래머스

SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프

programmers.co.kr


문제 풀이

i번째 논문 인용 횟수가 남은 논문 개수보다 클 경우 H-Index 조건 만족

import java.util.*;

class Solution {
		public int solution(int[] citations) {
			int answer = 0;
			Arrays.sort(citations);
			
			for(int i=0; i<citations.length; i++) {
			    int left = citations.length - i; // 남은 논문 개수
			    if(citations[i] >= left) {
                    		return left;
			    }
			}
			return answer;
		}
	}