c++ solution with explaination of modulo
Let say we have "011111". It produces 0, 1, 3, 7, 15, 31 . If we track modulo instead, we will have 0, 1, 3, 2, 0, 1  so the result is the same. we are interest
Let say we have "011111". It produces 0, 1, 3, 7, 15, 31 . If we track modulo instead, we will have 0, 1, 3, 2, 0, 1  so the result is the same. we are interested if our number is divisible by 5 or not. So to stop the overflow, modulo will make the number smaller and answer remain same. \n```\nclass Solution {\npublic:\n    vector<bool> prefixesDivBy5(vector<int>& nums) {\n        vector<bool> v;\n        int x = nums[0];\n        if(x==0) v.push_back(1);\n        else v.push_back(0); \n        for(int i=1;i<nums.size();i++)\n        {\n            x = 2*x + nums[i];\n            if(x%5==0)\n            {\n                v.push_back(1);\n            }\n            else\n            {\n                v.push_back(0);\n            }\n            x=x%5;     \n        }\n        return v;\n    }\n};\n```
['C++']