Given an unsorted integer array, find the smallest missing positive integer.
Input: [1,2,0] Output: 3
Input: [3,4,-1,1] Output: 2
Input: [7,8,9,11,12] Output: 1
Note: Your algorithm should run in O(n) time and uses constant extra space.
Solution: Please check the main.js snippet for the solution. If you have different approach in mind or have any suggestion for this implementation feel free to share in the comment below. Thanks!
Originally posted at: Github by @jeantimex