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

 

posted @ 2019-04-19 23:02  周洋  阅读(263)  评论(0编辑  收藏  举报