Simple method(Java)
When a binary number is appended by 0 , the new remainder can be calculated based on current remainder only.\nremainder = (remainder * 2) % 5;\n\nAnd when a bin
When a binary number is appended by 0 , the new remainder can be calculated based on current remainder only.\nremainder = (remainder * 2) % 5;\n\nAnd when a binary number is appended by 1.\n remainder = (remainder * 2 + 1) % 5;\n \n For example:\n If it is appended by 0 it will become 10 (2 in decimal) means twice of the last value.\n If it is appended by 1 it will become 11(3 in decimal), twice of last value +1.\n \n```\npublic List<Boolean> prefixesDivBy5(int[] A) {\n        List<Boolean> list = new ArrayList<>();\n        int remainder = 0;\n        for(int bit : A) {\n            if (bit == 1)\n                remainder = (remainder * 2 + 1) % 5;\n            if (bit == 0)\n                remainder = (remainder * 2) % 5;\n            if(remainder%5==0) {\n                list.add(true);\n            } else {\n                list.add(false);\n            }\n        }\n        return list;\n    }\n```
[]