==========================努力奋斗财源广进==========================
给定一个无重复元素的整数数组nums,请你找出其中没有出现的最小的正整数
提示:输出时按非降序排列。
import java.util.*;
public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param nums int整型一维数组 
     * @return int整型
     */
    public int minNumberDisappeared (int[] nums) {
        // write code here
        int length = nums.length;
        HashMap<Integer, Integer> res = new HashMap<>();
        for(int i = 0; i < length; i++)
        {
            res.put(nums[i], 1);
        }
        int ans = 1;
        while(res.containsKey(ans))
        {
            ans++;
        }
        return ans;
    }
}
//待定
评论区记录复习记录
评论