class Solution(object):
def searchInsert(self, nums, key):
left, right = 0, len(nums) - 1
while left <= right:
mid = left + (right - left) / 2
if nums[mid] >= target:
right = mid - 1
else:
left = mid + 1
return left
Good solution, but why?
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.