Solution: First Missing Positive
Explore how to find the smallest missing positive integer in an unsorted array using the cyclic sort pattern. This lesson helps you understand how to place elements in their correct positions iteratively to achieve O(n) time complexity and constant space usage. You will learn to implement an in-place sorting technique that identifies the first missing positive without extra memory allocation, preparing you to solve similar coding interview problems efficiently.
Statement
Given an unsorted integer array, nums, return the smallest missing positive integer.
Create an algorithm that runs with an 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 .
Constraints:
-
nums.length -
...