题解 | 出现奇数次的数

出现奇数次的数

https://www.nowcoder.com/practice/b3bd694fd4c44b89a5c6b49d855121b8

#include <iostream>
#include <map>
using namespace std;

int main() {
    int n;
    cin>>n;
    n*=2;
    n++;
    map<int,int>ms;
    while(n--){
       int temp;
       cin>>temp;
       ms[temp]++;
    }
    for(auto it=ms.begin();it!=ms.end();it++){
        if(it->second%2==1){
            cout<<it->first<<endl;
            break;
        }
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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