Skip to content

Commit 4cb6211

Browse files
Create 035_Search_Insert_Position.py
1 parent 17ed462 commit 4cb6211

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

035_Search_Insert_Position.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class Solution:
2+
def searchInsert(self, nums: List[int], target: int) -> int:
3+
if nums[-1] < target: return len(nums)
4+
elif nums[0] > target: return 0
5+
for i in range(len(nums)):
6+
if nums[i] == target: return i
7+
elif nums[i+1]>target: return i+1

0 commit comments

Comments
 (0)