Java O(N) | 100% Faster | Greedy
Intuition\nYou need to find the score for the whole array. And this will be the max score (with count = 1).\n\nThen you need to go through array using greedy ap
# Intuition\nYou need to find the score for the whole array. And this will be the max score (with count = 1).\n\nThen you need to go through array using greedy approach:\nYou apply bitwise AND operation until you find currAnd <= andMax. If you find such a subarray, then you sum this score.\n\nIf sum of scores is <= andMax, then you return count, else return 1.\n\n\n# Complexity\n- Time complexity: O(N)\n\n# Code\n```\nclass Solution {\n    public int maxSubarrays(int[] nums) {\n        if (nums.length == 1) return 1;\n        int andMax = nums[0], count = 0, currAnd = nums[0], sum = 0;\n        for (int n : nums) andMax &= n;\n        for (int i = 1; i < nums.length; i++) {\n            int n = nums[i];\n            if (currAnd <= andMax) {\n                count++;\n                sum += currAnd;\n                currAnd = n;\n            }\n            currAnd &= n;\n        }\n        if (currAnd <= andMax) {\n            count++;\n            sum += currAnd;\n        }\n        return sum <= andMax ? count : 1;\n    }\n}\n```
['Java']