Skip to main content
LeetCode 1060, Medium. Topics: Array, Binary Search. View on LeetCode. Generate this problem as a practice environment: tested reference solution, 12 parametrized pytest cases, and a playground notebook:

Problem

Given an integer array nums which is sorted in ascending order and all of its elements are unique and given also an integer k, return the kth missing number starting from the leftmost number of the array.

Examples

Constraints

  • 1 <= nums.length <= 5 * 10^4
  • 1 <= nums[i] <= 10^7
  • nums is sorted in ascending order, and all the elements are unique.
  • 1 <= k <= 10^8
Follow up: Can you find a logarithmic time complexity (i.e., O(log(n))) solution?

Solution

Reference implementation from solution.py on GitHub, full suite in test_solution.py:

Complexity

Tags

NeetCode All.
Last modified on September 7, 2026