3080. Split Array Into Maximum Number of Subarrays
My accepted Python solution to LeetCode problem 3080, Split Array Into Maximum Number of Subarrays, running in 49ms.
- Difficulty: Medium
- Python
- Runtime 49ms
- Memory 27.2MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 49ms, memory 27.2MB, accepted 2026-01-01.
class Solution:
def maxSubarrays(self, nums: List[int]) -> int:
total_and = nums[0]
for num in nums:
total_and &= num
if total_and != 0:
return 1
count = 0
curr_and = -1 # -1 in binary is all 1s
for num in nums:
curr_and &= num
if curr_and == 0:
count += 1
curr_and = -1
return count