LeetCode Explained ✅☑[C++] || Beats 100% || EXPLAINED🔥
Intuition\n Describe your first thoughts on how to solve this problem. \n\n- We know the result of a bitwise AND operation between two binary numbers can only b
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n- We know the result of a bitwise AND operation between two binary numbers can only be 0 or 1. \n- We initialize a variable a to INT_MAX. This is because the bitwise AND of the maximum possible value (INT_MAX) and any number will give us that number itself. (Note: INT_MAX in binary is 01111111111111111111111111111111)\n\n- Next, we calculate the bitwise AND of all the elements in the nums array. If this result is not equal to 0, it means that there is at least one subarray where the bitwise AND equal to one. In this case, the minimum possible answer is 1.\n\n- If the result from step 3 is 0, it implies that there exists at least one subarray with a bitwise AND equal to 0. In this scenario, we proceed to find other subarrays that can also have a bitwise AND equal to 0.\n\n- We count and track the subarrays that meet this condition and return the count as our final answer.\n\n\n\n\n# Code\n```\nclass Solution {\npublic:\n    int maxSubarrays(vector<int>& nums) {\n        int a=INT_MAX;\n        for(auto it:nums)a&=it;\n        if(a!=0)return 1;\n        int b=INT_MAX;\n        int count=0;\n        for(auto it:nums){\n            b&=it;\n            if(b==0){\n                count++;\n                b=INT_MAX;\n            }\n        }\n        return count;\n    }\n};\n```
['Bit Manipulation', 'Bitmask', 'C++']