尧图网络科技YAOTU DIGITAL 获取报价
获取报价
首页 / 资讯中心 / 文章详情

leetcode 困难题 1835. Find XOR Sum of All Pairs Bitwise AND

发布时间:2026/9/27 12:33:16

资讯中心
01
ARTICLE

leetcode 困难题 1835. Find XOR Sum of All Pairs Bitwise AND

leetcode 困难题 1835. Find XOR Sum of All Pairs Bitwise AND
Problem: 1835. 所有数对按位与结果的异或和数学题偶数个相同数字 和 另一个数组的一个数字AND结果相同也是偶数个偶数个相同数字的异或结果是0像【2 2】和【3】AND结果都是【1 1】两者的异或是0【2222】和【10】结果也是0所以偶数个数字的最终结果ANDXOR都是0只需要考虑奇数个数字并且只需要1个就行偶数个都抵消了哈希表Codeclass Solution { public: int getXORSum(vectorint arr1, vectorint arr2) { int n1 arr1.size(), n2 arr2.size(); unordered_mapint, int t1, t2; for(int i : arr1) t1[i]; for(int i : arr2) t2[i]; int ret 0; vectorint tr1, tr2; for(auto [k, l] : t1) { if((l1) 1) tr1.push_back(k); } for(auto [k, l] : t2) { if((l1) 1) tr2.push_back(k); } for(int k : tr1) { for(int kk: tr2) { ret ^ (k kk); } } return ret; } };
02
RELATED NEWS

相关资讯

更多网站建设与数字化升级内容

03
WHY YAOTU

想打造同款高转化官网?

懂行业、懂生意,从建站到增长一站式陪跑

◈

场景化定制

不做模板站,围绕你的业务场景量身设计,小众不撞款。

◐

营销型架构

以转化目标组织内容与路径,让官网真正带来询盘。

▲

全周期服务

设计、开发、运营、运维一体,上线只是开始。

免费获取你的建站方案

留下需求,专属顾问 24 小时内为你输出方案建议。