Skip to content

Commit 037c7ad

Browse files
committed
Time: 246 ms (36.45%), Space: 18 MB (13.13%) - LeetHub
1 parent 4823315 commit 037c7ad

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution:
2+
def search(self, nums: List[int], target: int) -> int:
3+
l,r = 0, len(nums)-1
4+
while l<=r:
5+
mid = (l+r)//2
6+
if target == nums[mid]: return mid
7+
if target < nums[mid]:
8+
r = mid-1
9+
else:
10+
l = mid+1
11+
return -1

0 commit comments

Comments
 (0)