Effective Greedy Solution
Approach\nWe can simply use a greedy approach here for the answer as the minimum answer for AND we can get is 0. So first take the and of all elements.if its no
# Approach\nWe can simply use a greedy approach here for the answer as the minimum answer for AND we can get is 0. So first take the and of all elements.if its not 0 then return 1 as the entire array can be taken.\n\nNow iterate through the array and check for zero AND product. Whenever 0 is achieved count increase by 1 and reset the product value to INT_MAX;\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n    int maxSubarrays(vector<int>& nums) \n    {\n        int totalAnd=INT_MAX;\n        for(auto i:nums)\n           totalAnd&=i;\n        if(totalAnd!=0)\n          return 1;\n        int curr=INT_MAX;\n        int count=0;\n        for(auto i:nums)\n        {\n            curr&=i;\n            if(curr==0)\n              {\n                  count++;\n                  curr=INT_MAX;\n              }\n        }\n        return count;\n    }\n};\n```
['C++']