思路:感觉像是暴力啊
// @Title: 缺失的第一个正数 (First Missing Positive)
// @Author: qisiii
// @Date: 2024-04-29 00:42:32
// @Runtime: 1 ms
// @Memory: 55.9 MB
// @comment: 感觉像是暴力啊
// @flag: RED
class Solution {
public int firstMissingPositive(int[] nums) {
int overflow = nums.length;
for (int i = 0; i < overflow; i++) {
if (nums[i] <= 0) {
nums[i] = overflow+1;
} else if (nums[i] > overflow ) {
nums[i] = overflow+1;
}
}
for (int i = 0; i < overflow; i++) {
int temp = Math.abs(nums[i]);
if (temp <= overflow) {
nums[temp-1] = -Math.abs(nums[temp-1]);
}
}
for (int i = 0; i < overflow; i++) {
if (nums[i] > 0) {
return i+1;
}
}
return overflow+1;
}
}