LeetCode 1018. Binary Prefix Divisible By 5 Posted on 2021-01-14 Edited on 2024-11-24 In LeetCode 123456789101112class Solution {public: vector<bool> prefixesDivBy5(vector<int>& A) { vector<bool> ans; int mask = 0; for (const int i : A) { mask = ((mask << 1) + i) % 5; ans.emplace_back(mask == 0); } return ans; }};