Leetcode 1071 Solution

This article provides solution to leetcode question 1071 (binary-prefix-divisible-by-5)

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