---
# System prepended metadata

title: 1060. Missing Element in Sorted Array
tags: ['2020', binary search, leetcode study group]

---

# 1060. Missing Element in Sorted Array
Given a sorted array A of **unique** numbers, find the K-th missing number starting from the leftmost number of the array.

###### tags: `binary search` `leetcode study group` `2020`
```python
class Solution:
    def missingElement(self, nums: List[int], k: int) -> int:
        # find the amount of missed elements
        def missed(idx):
            return nums[idx] - nums[0] - idx
        
        # binary search with low bound algo
        n = len(nums)
        left = 0
        right = n
        while left < right:
            mid = left + (right - left) // 2
            if missed(mid) < k:
                left = mid + 1
            else:
                right = mid
        
        
        return nums[left-1] + k - missed(left-1)
```
#### time complexity: O(logN)
#### space complexity: O(1)
>[name=Bruce]