Ruby O(n) solution, explained
Intuition\nThe key to this problem is understanding that expanding the subarray cannot increase its bitwise AND value.  (Also, it\'s only possible to have mulip
# Intuition\nThe key to this problem is understanding that expanding the subarray cannot increase its bitwise AND value.  (Also, it\'s only possible to have muliple subarrays and keep the minimum sum if bitwise AND of the whole array is 0.)  So we can just go through and find subarrays with a bitwise AND value of 0.\n\n# Approach\n1. Find the bitwise & of the whole array.  Return 1 if this is greater than 0: this means we can\'t have multiple subarrays.  (If we split it into multiple subarrays, each will have a value of at least min, and so their sum will be higher.)\n2. Initialize curr, i, and total_subarrs as 0.\n3. Iterate though the array.  For each element, find & with that and curr.\n    - If curr gets to 0, increment total_subarrs and reset curr.\n4. Return total subarrs\n\n(Note that curr will finish at a value other than 0: either nil, if you used the last element of the array in a subarray, or something else.  If it\'s not nil, you can just add the remaining elements from the end of the array to the last subarray that got to 0 -- it will still be 0.)\n\n# Complexity\n- Time complexity:\n$$O(n)$$\n\n- Space complexity:\n$$O(n)$$\n\n# Code\n```\ndef max_subarrays(nums)\n    min = nums[0]\n    (1...nums.length).each { |i| min &= nums[i] }\n    return 1 if min > 0\n    \n    i = 0\n    curr = nums[0]\n    total_subarrs = 0\n    \n    while i < nums.length\n        curr &= nums[i]\n        i += 1\n        if curr == 0\n            total_subarrs += 1\n            curr = nums[i]\n        end\n    end\n    \n    total_subarrs\nend\n```
['Ruby']