Find the First K Missing Positive Numbers

Try to solve the Find the First K Missing Positive Numbers problem.


Given an unsorted integer array, arr, of size nn and a number kk, your task is to find the first kk missing positive numbers from the array. If there are less than kk missing positive numbers in the array, then add the remaining missing numbers by adding the values after the last value of the array until we have kk missing positive numbers. Ignore all negative numbers.


  • n=n = arr.length

  • 1k1041 \leq k \leq 10^4

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

  • 0n1040 \leq n \leq 10^4


Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy