Problems

31. First Missing Positive

HardArrayGoogleMicrosoft

Return the smallest positive integer missing from an unsorted array in O(n) time and O(1) extra space.

Example 1:

Input: nums = [1,2,0]
Output: 3

Example 2:

Input: nums = [3,4,-1,1]
Output: 2

Constraints:

  • 1 <= nums.length <= 10^5
Core code mode
● Auto-savedLine 1, column 1