Leetcode 1071 Solution
This article provides solution to leetcode question 1071 (binary-prefix-divisible-by-5)
Access this page by simply typing in "lcs 1071" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/binary-prefix-divisible-by-5
Solution
class Solution:
def prefixesDivBy5(self, A: List[int]) -> List[bool]:
cur = 0
ans = []
for i, a in enumerate(A):
cur = cur * 2 + a
ans.append(cur % 5 == 0)
return ans