2871. Split Array Into Maximum Number of Subarrays
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n\nUnderstanding below test cases is half the answer:\n\nseries          a
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n\nUnderstanding below test cases is half the answer:\n```\nseries          ans \n[1,0,  1,0,1,1  ]\t2 <---------- important - maximize (0 AND) subarrays\n[1,0,  2,0,  1,2]\t3 <---------- important - maximize (0 AND) subarrays\n\n[1,0,  1,0,  1,0]\t3\n[1,2,  1,2,  1,2]\t3\n```\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n\n---\n\n```\nvar maxSubarrays = function (a) {\n  const MAX_ALL_ONES_IN_BINARY_FORM = 2 ** 32 - 1;\n  let count = 0;\n  let andValue = MAX_ALL_ONES_IN_BINARY_FORM;\n  for (const e of a) {\n    andValue = andValue & e;\n    if (andValue === 0) {\n      count++;\n      andValue = MAX_ALL_ONES_IN_BINARY_FORM;\n    }\n  }\n  if (a.length > 0) {\n    if (count === 0) {\n      count = 1;\n    }\n  }\n  return count;\n};\n```\n\n---\n
['JavaScript']