Subarray with equal occurences! Time : Space : 123456789101112int Solution::solve(vector<int> &A, int B, int C) { unordered_map<int, int> freq{{0,1}}; int b = 0, c = 0, res = 0; for(auto a : A) { if(a == B) b += 1; if(a == C) c += 1; res += freq[b-c]; freq[b-c] += 1; } return res;}