题解 | #缺失的第一个正整数#

缺失的第一个正整数

https://www.nowcoder.com/practice/50ec6a5b0e4e45348544348278cdcee5

#include <unordered_map>
class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param nums int整型vector 
     * @return int整型
     */
    int minNumberDisappeared(vector<int>& nums) {
        // write code here
        unordered_map<int, int> num_and_occur;
        for (auto& item : nums) {
            num_and_occur[item]++;
        }
        int i = 1;
        while (num_and_occur.count(i) > 0) {
            i++;
        }
        return i;
    }
};

在线编程练习 文章被收录于专栏

C++在线编程练习题解

全部评论

相关推荐

08-08 14:46
郑州大学 Java
点赞 评论 收藏
分享
点赞 评论 收藏
分享
在投简历的柠檬精很想...:可以明确说,问的东西几乎是简历上的东西。你写的确实有点模糊。面试可能会问你一些常用的通信的问题,差分信号走线之类的,单片机最小系统啥的,模电,数电,基本电源,buck,boost,ldo之类的吧。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务