Array-T41. First Missing Positive
Problem:Given an unsorted integer array, find the smallest missing positive integer.
Note:
Your algorithm should run in O(n) time and uses constant extra space.
Solve:
Thought:由于所给的列表为无序列表,且涉及最值问题,所以先对列表进行排序。设置一个变量来储存当前未出现的最小正整数。遍历列表即可找出缺少的最小正整数。