Skip to content

Commit 9e83351

Browse files
committed
Update search-for-a-range.py
1 parent cdfc802 commit 9e83351

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

Python/search-for-a-range.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ class Solution:
1717
# @param target, an integer to be searched
1818
# @return a list of length 2, [index1, index2]
1919
def searchRange(self, A, target):
20-
# This is main For binarySearch3()
21-
A += [float("inf")]
22-
2320
# Find the first index where target <= A[idx]
2421
left = self.binarySearch(lambda x, y: x <= y, A, target)
2522
if left >= len(A) or A[left] != target:
@@ -49,7 +46,7 @@ def binarySearch2(self, compare, A, target):
4946
return start
5047

5148
def binarySearch3(self, compare, A, target):
52-
start, end = -1, len(A) - 1
49+
start, end = -1, len(A)
5350
while end - start > 1:
5451
mid = start + (end - start) / 2
5552
if compare(target, A[mid]):

0 commit comments

Comments
 (0)