剑指offer40: 数组中只出现一次的数字
class Solution {
public:
    void FindNumsAppearOnce(vector<int> data,int* num1,int *num2) {
        map<int,int> mp;
        for(auto n:data)
            mp[n]++;
        map<int,int>::iterator it;
        int flag=1;
        for(it=mp.begin();it!=mp.end();it++)
        {
            if((it->second==1)&&(flag==1))
            {
                *num1 = it->first;
                flag++;
            }
            else if((it->second==1)&&(flag==2))
            {
                *num2 = it->first;
            }
        }
    }
};
2020-04-24
在牛客打卡15天,今天学习:刷题 2 道/代码提交 2 次
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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