Skip to content

Commit 4701ba1

Browse files
committedOct 15, 2023
Time: 228 ms (7.9%), Space: 17.9 MB (48.01%) - LeetHub
1 parent 2a81295 commit 4701ba1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
 
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution:
2+
def search(self, nums: List[int], target: int) -> int:
3+
if target not in nums:
4+
return -1
5+
6+
left, right = 0, len(nums)
7+
8+
while left < right:
9+
mid = (left + right) // 2
10+
if nums[mid] < target:
11+
left = mid + 1
12+
else:
13+
right = mid
14+
15+
return left

0 commit comments

Comments
 (0)
Please sign in to comment.