Java solution with best explanation(don't know why some explanation not concise)
Prerequisite\n\nYou need to know how to contruct a number with bits in some numeric representation. \n\nFor example: \n1. Contruct the number from a string in d
**Prerequisite**\n\nYou need to know how to contruct a number with bits in some numeric representation. \n\nFor example: \n1. Contruct the number from a string in decimal like `"12345678"`, key: `num = num * 10 + (c - \'0\')` where `c` is the current character.\n2. Contruct the number from a string in binary like `"01010101"`, key: `num = num * 2 + (c - \'0\')`,  and faster: `(num << 1) | (c - \'0\')` where `c` is the current character.\nOr array format like `[0, 1, 0, 1, 0, 1]`, key: `num = (num << 1) | c` where `c` is the current bit. \n\nYou should be already very familar with that.\n\n---\n**Strategy**\n\nIf you know above, then you can just contruct the number `num` and check if `num % 5 = 0` and add it to result `res`. \n\nBut **Trap**:\nIn Java, an integer `int` is a 32-bit number, that\'s why it is in range of `[-2^31, 2^31 - 1]`. So if we use above way, then it can maximumly represent 32 bits in the array `A`. If beyond that, then `overflow` will happen, you may not get correct result.  \n\nSo we need to use some **Math Knowledge**(I learnt it from Cryptography Course if my memory services my right):\nConsider the formula below which is the key to this problem:\n```\n(a * b + c) % d = ((a % d) * (b % d) + c % d) % d\n```\n\nSimply say is that we mod each part in `a * b + c`, then mod the result.\n\nSo in this problem, `num = (num << 1) + cur` which can be written as `num = num * 2 + (0 or 1)`. From above trick, we get `num % 5 = (num % 5) * (2 % 5) + (0 or 1) % 5`. Since `2`, `0`, `1` all smaller than 5, so they mod 5 do not cause any difference, we simplify the formula to => `num % 5 = 2 * (num % 5) + (0 or 1)`. \n\nFrom above we know that we can update `num` to `num % 5` each time which then avoids `overflow` for us.\n\n---\n**Final Code**\n\n```java\nclass Solution {\n    public List<Boolean> prefixesDivBy5(int[] A) {\n        List<Boolean> res = new ArrayList<>();\n        int num = 0;\n        for(int cur : A){\n            num = ((num << 1) + cur) % 5;\n            if(num == 0) res.add(true);\n            else res.add(false);\n        }\n        \n        return res;\n    }\n}\n```\n\n---\nTC: `O(n)` where `n` is the length of `A`\nSC: `O(1)`\n\n---\n**One more thing**\n\nIf you have any confusion or an opinon on the description, please comment, I will insist on updating it for **at least 100 years**.
[]