Skip to content

Commit a6f5f5c

Browse files
committed
Add C++ solution of problem #2425
1 parent c75bb51 commit a6f5f5c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

2425/solution.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// If the size of nums1 is m and the size of nums2 is n, then each number in
2+
// nums1 is repeated n times and each number in nums2 is repeated m times.
3+
4+
class Solution {
5+
public:
6+
int xorAllNums(vector<int>& A, vector<int>& B) {
7+
int ans = 0;
8+
if(A.size() % 2 == 1) {
9+
for(int b : B)
10+
ans ^= b;
11+
}
12+
if(B.size() % 2 == 1) {
13+
for(int a : A)
14+
ans ^= a;
15+
}
16+
return ans;
17+
}
18+
};

0 commit comments

Comments
 (0)