Back to course home
0% completed
Solution: First Missing Positive
Problem Statement
Given an unsorted array nums
containing positive and negative integers, return the smallest
missing
positive integer value.
Note: You must implement algorithm in o(n) time and uses o(1) space.
Examples
-
Example 1:
- Input: [5, 3, -1, 8, 4, 2]
- Expected Output: 1
- Justification: The first missing positive integer in the array is 1.
-
Example 2:
- Input: [2, 5, -7, 3, 9, 4, 6, 1]
- Expected Output: 7
.....
.....
.....
Like the course? Get enrolled and start learning!