why greedy
Intuition\n Describe your first thoughts on how to solve this problem. \nThe answer is obtained by greedily taking the interval where & in nums becomes 0 from i
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe answer is obtained by greedily taking the interval where & in nums becomes 0 from i=0.\n\nSuppose that when nums[i]&nums[i+1]&...&nums[j]=0, the interval is not separated by the jth interval. Even if we take (j<k), nums[i]&...&nums[k]=0. Suppose that after doing so, we were able to take the next interval {k+1,..,v}. Here, nums[k+1]&...&nums[v]=0, so nums[j]&...&(nums[k+1]&...&nums[v])=0. Therefore, you can also create an interval with {j~v}. So, the minimum cost is greedily take j.\n\nLet the above answer be ans.\nHere, the last interval {L,...,n-1} may not be 0. At that time, even if you separate the intervals within this interval (because there is a certain digit where all nums in this interval are 1), you cannot set it to 0 using the "& operation". Therefore, at least L needs to be extended to the left. In this case, in order to make the answer greater than or equal to ans+1, it is necessary to divide the interval within the "second to last interval" into two or more parts, but if that is possible, then L is not a greedy solution. So it\'s not possible.\n\nTherefore, this interval needs to be merged with the "previous interval". And that interval turns out to be the best answer. So, taking it greedy is the answer.\nI apologize if there are any mistakes or incorrect descriptions.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int maxSubarrays(vector<int>& nums) {\n        int n=nums.size();\n        int s=nums[0];\n        for(int x:nums){\n            s&=x;\n        }\n        if(s!=0){\n            return 1;\n        }\n        int ans=0;\n        for(int i=0;i<n;){\n            int s=nums[i];\n            int j=i+1;\n            ans++;\n            while(j<n&&s!=0){\n                s&=nums[j];\n                j++;\n            }\n            if(s!=0){\n                ans--;\n            }\n            //cout<<i<<" "<<j<<endl;\n            i=j;\n        }\n        return ans;\n    }\n};\n```
['C++']