Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int getChannelRating(vector<int> &views)
- {
- long long ans = 0;
- long long modd = 1e9 + 7;
- map<long long, long long> m;
- m[0]++;
- long long p = 0;
- vector<long long> pre(views.size());
- for (int i = 0; i < views.size(); i++)
- {
- p ^= views[i];
- if (i >= 2)
- {
- ans += m[p];
- ans %= modd;
- if (pre[i - 1] == p)
- {
- ans--;
- ans %= modd;
- }
- }
- m[p]++;
- pre[i] = p;
- }
- return ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement