Easy C++ Binary Prefix Divisible By 5
Naive Solution\nRefrence - https://leetcode.com/problems/binary-prefix-divisible-by-5/discuss/265601/Detailed-Explanation-using-Modular-Arithmetic-O(n)\n\n\ncla
# Naive Solution\nRefrence - https://leetcode.com/problems/binary-prefix-divisible-by-5/discuss/265601/Detailed-Explanation-using-Modular-Arithmetic-O(n)\n\n```\nclass Solution {\npublic:\n    vector<bool> prefixesDivBy5(vector<int>& A) {\n        vector<bool> lks;\n        int n=0;\n        for(auto x:A){\n            n=(n*2+x)%5;\n            lks.push_back(n==0);\n        }\n        return lks;\n    }\n};\n```\n\n# Bitwise Solution\n```\nclass Solution {\npublic:\n    vector<bool> prefixesDivBy5(vector<int>& A) {\n        vector<bool> lks;\n        int n=0;\n        for(auto x:A){\n            n=(n<<1 | x)%5;\n            lks.push_back(n==0);\n        }\n        return lks;\n    }\n};\n```\n# TOC Solution\nRefrence - https://leetcode.com/problems/binary-prefix-divisible-by-5/discuss/800137/C%2B%2B-simple-Transition-graph-99-fast\n\n```\nclass Solution {\npublic:\n    vector<bool> prefixesDivBy5(vector<int>& A) {\n        int q = 0; \n        vector<bool> lks(A.size());\n        \n        for(int i=0; i<A.size(); i++){\n            int n = A[i];\n            if(q == 0) q = n;   \n            else if(q == 1) q = 2 + n;       \n            else if(q == 2) q = n == 1 ? 0 : 4; \n            else if(q == 3) q = q - (2-n);  \n            else if(q == 4) q = q - (1-n);   \n            lks[i] = q == 0; \n        }\n        return lks;\n    }\n};\n```
['C']