Given an unsorted integer array nums, return the smallest missing positive integer.
The classic optimal solution runs in linear time and uses constant extra space by reusing the input array itself as bookkeeping.
Input / output
nums: int[]intExamples
nums = [1,2,0] returns 3.nums = [3,4,-1,1] returns 2.nums = [7,8,9,11,12] returns 1.Constraints
1 <= nums.length <= 100000-2^31 <= nums[i] <= 2^31 - 1Follow-up
Can you solve it in O(n) time and O(1) extra space, and explain why values outside the range 1..n can be ignored?