First Missing Positive Integer

Given an array of integers, find the smallest missing positive integer.


Given an unsorted integer array, nums, find the smallest positive integer that is missing from the array.

Implement a solution that takes O(n)O(n) time and constant space.


Let’s look at some arrays and the first missing positive integer in each:

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.