2588.cpp (376B)
1 class Solution { 2 public: 3 long long beautifulSubarrays(const vector<int> &nums) const { 4 static int count[1048577]; 5 long long res = 0; 6 int crnt = 0; 7 8 memset(count, 0x00, sizeof(count)); 9 count[0] = 1; 10 for (const int n : nums) { 11 crnt ^= n; 12 res += count[crnt]++; 13 } 14 15 return res; 16 } 17 };