package leetcode; import java.util.Arrays; public class HindexSolution { public int hIndex(int[] citations) { Arrays.sort(citations); for(int i =0 ; i < citations.length ; i++){ if(citations[i] >=citations.length-i){ return citations.length - i ; } } return 0; } public static void main(String[] args){ int[] citations = {3,0,1,5,4,4} ; int hi = new HindexSolution().hIndex(citations); System.out.println(hi); } }