Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def getChannelRating(views):
- ans = 0
- modd = 10 ** 9 + 7
- m = {}
- m[0] = 1
- p = 0
- pre = [0] * len(views)
- for i in range(len(views)):
- p ^= views[i]
- if i >= 2:
- ans += m.get(p, 0)
- ans %= modd
- if views[i] == 0:
- ans -= 1
- if views[i] == views[i - 1]:
- ans -= 1
- if ans < 0:
- ans += modd
- m[p] = m.get(p, 0) + 1
- pre[i] = p
- return ans
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement