Java O(n) solution with explaination
\n\n/* \n * First thing first, note that by adding a zero bit digit to any binary\n * number, we get a new binary number that represent double of the original b
```\n\n/* \n * First thing first, note that by adding a zero bit digit to any binary\n * number, we get a new binary number that represent double of the original binary value.\n * Similarly, adding a 1 bit digit yields original value * 2 + 1.\n * So we can walk the binary array nums from left to right,\n * starting from the first binary value at nums[0], and then\n * obtain the binary value of each next iteration with one additional\n * bit added to the end from (previousBinaryValue*2)+newBinaryValueAddedAtEnd\n * \n * Furthermore, we don\'t even need to store each of those binary value fully.\n * Decimal number are only divisible by 5 iff it have either 0 or \n * 5 as their least signficant digit. and the least signficiantly bit\n * of each number is the only information one needed to get the least signficant bit\n * of the result value evaulated using addition and multiplication, i.e. the above\n * next iteration calculation formula. So we only need to store the lsd value of previous\n * value at each iteration, which is constant memory and also constant arithmetic\n * cost with all party involves always being 1 bit in size. This makes this algorithmn\n * scale signficantly better with large input, placing it at\n * O(n) both in terms of runtime and space.\n *\n * For further explaination on only needing the least signficant digit / last digit for each\n * calculation, think that no matter what digit value in any other significant position of \n * any decimal number, only the lsd of the number affects the lsd of\n * the new number produced in any addition and multiplciation arithmetic: \n * 2+7 = 9, 4372859(2) + 497346(7) = 4870205(9),\n * 4*6 = 2(4), 674995(4) * 764249(6) = 5158649644518(4)\n */\nclass Solution {\n    public List<Boolean> prefixesDivBy5(int[] nums) {\n        if(nums.length == 0)\n            throw new Error("empty binary array input");\n        \n        int lastDigit = 0; // (0 * 2)+nums[0] = nums[0], initialize to 0 so as to not affect first iteration\n        List<Boolean> result = new ArrayList<>();\n        \n        /* walk the array, calculate binary value at each interval, and determine if it\'s divisible by 5 */\n        for(int i = 0; i < nums.length; i++){\n            lastDigit = (lastDigit*2 + nums[i]) % 10; // trim off unnecessary bits\n            if(lastDigit == 0 || lastDigit == 5){\n                result.add(true);\n            }\n            else{\n                result.add(false);\n            }\n        }\n        // done\n        return result;\n    }\n}\n```
[]