three lines java solution O(n)


  • 0
    J
    public class Solution {
        public int hIndex(int[] citations) {
    		Arrays.sort(citations);
    		for(int index=0;index<citations.length;index++)		if(citations[index]>=citations.length-index) return citations.length-index;
    		return 0;
    	        
    	}
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.