A couple of different solutions in Python
Here is the first solution:\n\npython\nclass Solution:\n    def prefixesDivBy5(self, A):\n        result = []\n        number = 0\n        for bit in A:\n      
Here is the first solution:\n\n```python\nclass Solution:\n    def prefixesDivBy5(self, A):\n        result = []\n        number = 0\n        for bit in A:\n            number = 2*number + bit\n            result.append(number % 5 == 0)\n        return result\n```\n\nThe idea is simple: we accumulate the bits into a binary number as we traverse the list. To append another bit to the number you need only to multiply the number by two (equivalent to shifting all the bits left by one place) and then add the bit. We then determine whether the number is divisible by five with the `%` operator.\n\nWe can make this significantly more efficient by storing only the remainder of the number (modulo five). This works because if ![image](https://assets.leetcode.com/users/lxnn/image_1563104573.png), then ![image](https://assets.leetcode.com/users/lxnn/image_1563104586.png).\n\n```python\nclass Solution:\n    def prefixesDivBy5(self, A):\n        result = []\n        remainder = 0\n        for bit in A:\n            remainder = (2*remainder + bit) % 5\n            result.append(remainder == 0)\n        return result\n```\n\nIn fact, this is essential if you are writing your solution in a language like C, where your integers are at risk of overflowing.\n\n<hr>\n\nAnd here is an alternative one-liner(ish) solution in Python, which takes the same approach but in a more functional-programming style:\n\n```python\nfrom itertools import accumulate\n\nclass Solution:\n    def prefixesDivBy5(self, A):\n        \n        def append_bit_take_mod(num, bit):\n            return (2*num + bit) % 5\n        \n        def equals_zero(num):\n            return num == 0\n        \n        return list(map(equals_zero, accumulate(A, append_bit_take_mod)))\n```
[]