Practice First Missing Positive
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Given an unsorted integer array nums. Return the smallest positive integer that is not present in nums. You must implement an algorithm that runs in O(n) time and uses O(1) auxiliary space.
Source: First Missing Positive on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [1,2,0]
Output
3
# Example 2
Input
nums = [3,4,-1,1]
Output
2
# Example 3
Input
nums = [7,8,9,11,12]
Output
1
Constraints
1 <= nums.length <= 10^5
-2^31 <= nums[i] <= 2^31 - 1
Related LeetCode Problems
Practice more problems similar to First Missing Positive.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.