class Solution {
public:
/*
*
* @param A int整型一维数组
* @param n int A数组长度
* @return int整型
*/
int firstMissingPositive(int
A, int n) {
// write code here
vector<int> result(n, 0);
for(int i = 0; i < n; i++){
if(A[i] <= 0 || A[i] > n) continue;
result[A[i] - 1]++;
}
for(int i = 0; i < n; i++){
if(result[i] == 0) return i + 1;
}
return n + 1;
}
};</int>