Java || 4ms Solution || 56% Beats || Easy to Understand || O(N) Solution
\n\n# Intuition\nI want to check the And of all the bits first and if it is non-zero then simply return 1\n\n# Approach\nFinding the And of all the elements ini
![image.png](https://assets.leetcode.com/users/images/4433d023-e912-4c5e-bd36-6d3a4e828187_1704434212.4855177.png)\n\n# Intuition\nI want to check the And of all the bits first and if it is non-zero then simply return 1\n\n# Approach\nFinding the And of all the elements initially and deciding weather we can split the array into sub-arrays or not\nif it is not possible then simply return 1 else try to divide into sub-arrays by simply using And for all total elements on it and keep counter variable for keeping count values.\n\n# Complexity\n- Time complexity:\nO(N)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\n    public int maxSubarrays(int[] nums) {\n        int totalAnd = nums[0];\n        for(int num: nums) totalAnd &= num;\n        if(totalAnd != 0) return 1;\n        int count = 0;\n        totalAnd = nums[0];\n        for(int i = 0;i<nums.length;i++){\n            if(totalAnd == 0){\n                totalAnd = nums[i];\n            }\n            totalAnd&=nums[i];\n            if(totalAnd == 0) count++;\n        }\n        return count;\n    }\n}\n```
['Java']