Tap here to switch tabs
Problem
Submissions

Problem: Find the First K Missing Positive Numbers

Find the First K Missing Positive Numbers asks you to return the first k positive integers absent from an unsorted array, ignoring zeros and negatives and extending beyond its largest value when needed.

Statement

Given an unsorted integer array, arr, of size n and an integer k, find the first k missing positive integers from the array, ignoring all negative numbers and zeros.

If the array does not contain enough missing positive numbers, add the next consecutive positive integers, starting from the smallest number greater than the largest value in the array, until exactly k missing positive numbers have been found.

Return the list of the first k missing positive integers, sorted in ascending order.

Constraints:

  • n=n = arr.length

  • 1≤k≤1041 \leq k \leq 10^4

  • −104≤-10^4 \leq arr[i] ≤104\leq 10^4

  • 0≤n≤1040 \leq n \leq 10^4

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find the First K Missing Positive Numbers

Find the First K Missing Positive Numbers asks you to return the first k positive integers absent from an unsorted array, ignoring zeros and negatives and extending beyond its largest value when needed.

Statement

Given an unsorted integer array, arr, of size n and an integer k, find the first k missing positive integers from the array, ignoring all negative numbers and zeros.

If the array does not contain enough missing positive numbers, add the next consecutive positive integers, starting from the smallest number greater than the largest value in the array, until exactly k missing positive numbers have been found.

Return the list of the first k missing positive integers, sorted in ascending order.

Constraints:

  • n=n = arr.length

  • 1≤k≤1041 \leq k \leq 10^4

  • −104≤-10^4 \leq arr[i] ≤104\leq 10^4

  • 0≤n≤1040 \leq n \leq 10^4