Skip to main content
Back to problems
Leetcode
Medium
Arrays
Binary Search
Kth Missing Positive Number

Find the kk-th positive integer that does not appear in a strictly increasing sorted array.

Acceptance 0%
Problem Statement

You are given a strictly increasing array of positive integers. Some positive integers are missing from the array.

Return the kk-th positive integer that does not appear in the array when counting missing positive numbers in increasing order starting from $1$.

The array is already sorted and contains no duplicates, so you should use that structure to find the answer efficiently.

Input Format

  • An integer array arr of strictly increasing positive integers.
  • An integer k representing which missing positive number to return.

Output Format

Return the kk-th missing positive integer.

Constraints

  • 1 <= arr.length
  • 1 <= arr[i]
  • arr is strictly increasing
  • 1 <= k
  • The answer fits in a 32-bit signed integer
Examples
Sample cases returned by the problem API.

Example 1

Input

arr = [2,3,4,7,11], k = 5

Output

9

Explanation

The missing positive numbers are 1, 5, 6, 8, 9, 10, ... The 5th missing number is 9.

Example 2

Input

arr = [1,2,3,4], k = 2

Output

6

Explanation

The missing positive numbers are 5, 6, 7, ... The 2nd missing number is 6.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.