File tree Expand file tree Collapse file tree 3 files changed +76
-53
lines changed
src/main/java/com/github/chen0040/leetcode/day21/medium Expand file tree Collapse file tree 3 files changed +76
-53
lines changed Original file line number Diff line number Diff line change @@ -430,3 +430,4 @@ codes may not be optimized
430
430
1 . [ Permutation Sequence] ( https://leetcode.com/problems/permutation-sequence/description/ )
431
431
1 . [ Next Permutation] ( https://leetcode.com/problems/next-permutation/description/ )
432
432
1 . [ H-Index] ( https://leetcode.com/problems/h-index/description/ )
433
+ 1 . [ H-Index II] ( https://leetcode.com/problems/h-index-ii/description/ )
Original file line number Diff line number Diff line change
1
+ package com .github .chen0040 .leetcode .day21 .medium ;
2
+
3
+
4
+ /**
5
+ * Created by xschen on 16/8/2017.
6
+ *
7
+ * link: https://leetcode.com/problems/h-index-ii/description/
8
+ */
9
+ public class HIndexII {
10
+ public class Solution {
11
+ public int hIndex (int [] citations ) {
12
+ int lo = 0 ;
13
+ int hi = citations .length - 1 ;
14
+ while (lo <= hi ) {
15
+ int mid = lo + (hi -lo ) / 2 ;
16
+ int h = citations .length - mid ;
17
+ if (citations [mid ] < h ){
18
+ lo = mid + 1 ;
19
+ } else if (citations [mid ] >= h ) {
20
+ hi = mid - 1 ;
21
+ }
22
+ }
23
+ return citations .length - lo ;
24
+ }
25
+ }
26
+ }
You can’t perform that action at this time.
0 commit comments