Solution Nice | HASHING


#1
int Solution::solve(vector<int> &A, int B) {
    int size = A.size();
    int ans = 0;
    for(int i=1; i<size; ++i) {
        A[i] ^= A[i-1];
    }
    unordered_map<int, int> hm;
    for(int i=0; i<size; ++i) {
        int find_v = B^A[i];
        ans += hm[find_v];
        if(find_v==0)
            ans++;
        hm[A[i]]++;
    }
    return ans;
}