-
[Programmers] H-IndexSTUDYING/Algorithm 2021. 9. 27. 00:45728x90
https://programmers.co.kr/learn/courses/30/lessons/42747
import java.util.*; class Solution { public int solution(int[] citations) { int answer = 0; Arrays.sort(citations); // System.out.println(Arrays.toString(citations)); for(int i = citations.length; i > 0; i--) { int h = i; int lower = 0; int higher = 0; for (int j = 0; j < citations.length; j++) { if (citations[j] >= h) { higher += 1; } else { lower += 1; } } if (higher >= h && lower <= h) { return h; } } return answer; } }
'STUDYING > Algorithm' 카테고리의 다른 글
재귀 (0) 2021.10.14 조합 (0) 2021.10.05 [Programmers] 경주로 건설 (0) 2021.09.27 [Programmers] 자연수 뒤집어 배열로 만들기 (0) 2021.09.27 [Programmers] 수박수박수박수박수박수? (0) 2021.09.27