Skip to content

Commit 5a3a977

Browse files
authoredNov 17, 2018
Create Solution.py
1 parent 5cb92a1 commit 5a3a977

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Solution:
2+
def searchInsert(self, Arr, find):
3+
"""
4+
:type Arr: list[int]
5+
:type find: int
6+
:rtype: int
7+
"""
8+
9+
left = 0
10+
right = len(Arr)-1
11+
12+
while left <= right :
13+
mid = (left + right)//2
14+
15+
if Arr[mid] == find :
16+
return mid
17+
elif Arr[mid] < find :
18+
left = mid + 1
19+
else:
20+
right = mid - 1
21+
22+
return left

0 commit comments

Comments
 (0)
Please sign in to comment.