035 Search Insert Position
二分法, 最后注意一下输出的时候要和 nums[left]比较一下来决定输出多少
class Solution: # @param {integer[]} nums # @param {integer} target # @return {integer} def searchInsert(self, nums, target): return self.help(nums, target, 0, len(nums)-1) def help(self, a, t, left, right): while left < right: mid = (left + right) / 2 if a[mid] == t: return mid elif a[mid] < t: left = mid + 1 else: right = mid - 1 if t > a[left]: return left + 1 else: return left