Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import defaultdict
- def getChannelRating(views):
- ans = 0
- m = defaultdict(int)
- m[0] = 1
- p = 0
- pre = [0] * len(views)
- for i in range(len(views)):
- p ^= views[i]
- if i >= 2:
- ans += m[p]
- if pre[i - 1] == p:
- ans -= 1
- m[p] += 1
- pre[i] = p
- return ans
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement