[Java] ✅ PREFIX AND ✅ 3MS ✅ FAST ✅ BEST ✅ CLEAN CODE
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n1. Calculate the AND prefix of ALL numbers. This prefix will be the lowes
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n1. Calculate the AND prefix of ALL numbers. This prefix will be the lowest prefixAnd that can be achieved.\n2. If prefixAnd is 0, then we can try to split it in as many chunks as possible, because 0 + 0 +.. + 0 = 0. The sum of all chunks is 0.\n3. However, if the prefix is not zero (eg: 7), splitting it into more chunks will lead to a sum of 7+7+..+7. \n    - This is greater than 1 single chunk with prefix 7, so we only need to split it into 1 chunk, just to obtain the minumum score.\n\n# Complexity\n- Time complexity:$$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n    public int maxSubarrays(int[] nums) {\n        int minAnd = nums[0];\n        for (int num : nums) {\n            minAnd &= num;\n        }\n        if (minAnd != 0) {\n            return 1;\n        }\n        int segments = 0, prefixAnd = nums[0];\n        for (int i = 0; i < nums.length; i++) {\n            prefixAnd &= nums[i];\n            if (prefixAnd == minAnd) {\n                segments++;\n                prefixAnd = i < nums.length - 1 ? nums[i+1] : -1;\n            }\n        }\n        return segments;\n    }\n}\n```
['Java']