Skip to content

Commit e633f74

Browse files
authored
Create 2425. Bitwise XOR of All Pairings (#690)
2 parents 3ef3c06 + 8cb8552 commit e633f74

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

2425. Bitwise XOR of All Pairings

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public:
3+
int xorAllNums(vector<int>& nums1, vector<int>& nums2) {
4+
int n1=nums1.size(), n2=nums2.size();
5+
unordered_map<int,long>freq;
6+
for(int n:nums1) freq[n]+=n2;
7+
for(int n:nums2) freq[n]+=n1;
8+
int res=0;
9+
for(auto& [n,c]:freq){
10+
if(c%2==1) res^=n;
11+
}
12+
return res;
13+
}
14+
};

0 commit comments

Comments
 (0)