Skip to content

Commit

Permalink
Create 2425. Bitwise XOR of All Pairings (#690)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chayandas07 authored Jan 16, 2025
2 parents 3ef3c06 + 8cb8552 commit e633f74
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions 2425. Bitwise XOR of All Pairings
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class Solution {
public:
int xorAllNums(vector<int>& nums1, vector<int>& nums2) {
int n1=nums1.size(), n2=nums2.size();
unordered_map<int,long>freq;
for(int n:nums1) freq[n]+=n2;
for(int n:nums2) freq[n]+=n1;
int res=0;
for(auto& [n,c]:freq){
if(c%2==1) res^=n;
}
return res;
}
};

0 comments on commit e633f74

Please sign in to comment.