Created
March 2, 2017 21:01
-
-
Save leearmee35/d7d24302863a8c20b8e7cee3e96aff16 to your computer and use it in GitHub Desktop.
275. H-Index II
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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