First Missing Positive

Try to solve the First Missing Positive problem.

Statement

Given an unsorted integer array, nums, return the smallest missing positive integer. Create an algorithm that runs with an O(n)O(n) time complexity and utilizes a constant amount of space.

Note: The smallest missing positive isn’t the first positive number that’s missing in the range of elements in the input, but the first positive number that’s missing if we start from 11.

Constraints:

  • 11 \leq nums.length 103\leq 10^3

  • 231-2^{31} \leq nums[i] 2311\leq 2^{31} - 1

Create a free account to view this lesson.

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