Skip to content

Instantly share code, notes, and snippets.

@leearmee35
Created March 2, 2017 21:01
Show Gist options
  • Save leearmee35/d7d24302863a8c20b8e7cee3e96aff16 to your computer and use it in GitHub Desktop.
Save leearmee35/d7d24302863a8c20b8e7cee3e96aff16 to your computer and use it in GitHub Desktop.
275. H-Index II
public class Solution {
public int hIndex(int[] citations) {
int low = 0, high = citations.length-1;
int res = 0;
while(low<=high){
int mid = low+(high-low)/2;
System.out.println(mid);
int h = citations.length-mid;
System.out.println(h);
if(citations[mid]>=h){
res = h;
high = mid-1;
} else {
low = mid+1;
}
}
return res;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment