Leetcode 1018. Binary Prefix Divisible By 5

class Solution:
    def prefixesDivBy5(self, A: List[int]) -> List[bool]:
        ans,t = [],0
        for a in A:
            t = (t * 2 + a)%5
            ans.append(False if t else True)
        return ans

猜你喜欢

转载自www.cnblogs.com/zywscq/p/10739388.html