2425.cpp (313B)
1 class Solution { 2 public: 3 int xorAllNums(const vector<int> &nums1, const vector<int> &nums2) const { 4 int a = 0, b = 0; 5 for (const int n : nums1) 6 a ^= n; 7 for (const int n : nums2) 8 b ^= n; 9 return (nums2.size() % 2 * a) ^ (nums1.size() % 2 * b); 10 } 11 };