*1060. Missing Element in Sorted Array

https://leetcode.com/problems/missing-element-in-sorted-array/

solution

class Solution:
    def missingElement(self, nums: List[int], k: int) -> int:
        minn = nums[0]

        left = 0
        right = len(nums) - 1
        while left < right:
            mid = left + (right - left + 1) // 2

            if nums[mid] >= minn + k + mid:
                right = mid - 1
            else:
                left = mid
        return minn + left + k

时间复杂度:O() 空间复杂度:O()

follow up

658. Find K Closest Elements

# 找到起点

Last updated