FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
LeetCode-Solutions/Python/h-index-ii.py at master · lightwindy/LeetCode-Solutions · GitHub
lightwindy
LeetCode-Solutions
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
LeetCode-Solutions
/
Python
/
h-index-ii.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
19 lines (17 loc) · 440 Bytes
Breadcrumbs
LeetCode-Solutions
/
Python
/
h-index-ii.py
Copy path
File metadata and controls
19 lines (17 loc) · 440 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Time: O(logn)
# Space: O(1)
class
Solution
(
object
):
def
hIndex
(
self
,
citations
):
"""
:type citations: List[int]
:rtype: int
"""
n
=
len
(
citations
)
left
,
right
=
0
,
n
-
1
while
left
<=
right
:
mid
=
(
left
+
right
)
/
2
if
citations
[
mid
]
>=
n
-
mid
:
right
=
mid
-
1
else
:
left
=
mid
+
1
return
n
-
left
Back
|
FazBrowse Home
|
New Git URL