One pass Simple JAVA solution


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

Log in to reply
 

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