You are given an unsorted list of integers. Your task is to find the smallest positive number that is not in the list.
You should solve this in linear time O(n) and constant extra space O(1).
Input: nums = [2,3,1]
Output: 4
Explanation:
Numbers 1, 2, 3 are present, so the smallest missing positive is 4.
Input: nums = [4,1,5,2]
Output: 3
Explanation:
1, 2, 4, 5 are present, but 3 is missing.
Input: nums = [7,8,9]
Output: 1
Explanation:
1 is the smallest positive number and it is missing.
Accepted:
Submission: