Simple Java Solution With Explanation
Idea\ncurr keeping track of decimal representation so far. When scanning from right, if we multiply curr by 2, it will shift all the bits in curr to left to mak
**Idea**\n`curr` keeping track of decimal representation so far. When scanning from right, if we multiply `curr` by 2, it will shift all the bits in `curr` to left to make place for the incoming digit `i`. That way, we are reusing the computations. We are not interested in the actual number, so to avoid overflow, we can subtract 5 as many times as possible (i.e. modulo by 5) and still validate if it is divisible by 5.\n\n```\npublic List<Boolean> prefixesDivBy5(int[] A) {\n        List<Boolean> res = new ArrayList<>();\n        int curr = 0;\n        for(int i : A){\n            curr = 2*curr+i;\n            curr %= 5;\n            res.add(curr == 0);\n        }\n        return res;\n    }\n```
[]