public class Solution { public int hIndex(int[] citations) { int answer=0; int size=citations.length; for(int i=0;i<size;i++) { int temp=0; if(citations[i]<=size-i) temp=citations[i]; else temp=size-i; answer=answer>temp?answer:temp; } return answer; } }