[C++] Time Complexity - O(N) and constant space complexity
We want the maximum subarray, so the input array given to us, can also be considered as a subarray, so if the bitwise and of all the elements is not zero then t
We want the maximum subarray, so the input array given to us, can also be considered as a subarray, so if the bitwise and of all the elements is not zero then the sum of the scores of subarray cannot be minimized if we divide it in multiple subarrays, but if the value is 0 then we can say that the scores of minimum 2 subarrays can be 0.\n\nclass Solution {\npublic:\n    int maxSubarrays(vector<int>& nums) {\n        int n=nums.size();\n        if(n == 1)\n            return 1;\n        int x=nums[0];\n        for(int i=1;i<n;i++){\n            x=x&nums[i];\n        }\n        if(x)\n            return 1;\n        int cnt=0,val=0;\n        for(int i=0;i<n;i++){\n            int j=i;\n            int num=nums[i];\n            if(num == 0){\n                cnt++;\n                continue;\n            }\n            while(j<n){\n                num=num&nums[j];\n                if(num == x){\n                    break;\n                }\n                j++;\n            }\n            if(j!=n){\n                cnt++;\n            }\n            val+=num;\n            i=j;\n        }\n        \n        return cnt;\n    }\n};\n\nTC - O(n) WHERE n is the size of array\nSC - O(n) WHERE n is the size of the array
['C++']