BackmediumArrays arrays medium

First Missing Positive Integer Solution

Problem Statement

Given an array of integers `arr` and an integer `k`, find the first missing positive integer such that each of the first `k` positive integers appear exactly once, and `arr` contains some, possibly none, of these positive integers.

Example 1
Input
5 5 1 2 3 4 5
Output
6

Explanation: First missing positive integer after 1 to 5

Constraints

  • 1 <= nums.length <= 100
  • 1 <= k <= 100
  • -1000 <= nums[i] <= 1000
  • Given array contains at most 3*k different integers.
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free