Skip to content

Practice Split Array Into Maximum Number of Subarrays

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2871
LeetCode Problem

Split Array Into Maximum Number of Subarrays

Problem Statement

Partition nums into nonempty contiguous subarrays covering every entry exactly once. A subarray score is the bitwise AND of all its entries. First minimize the sum of subarray scores; among partitions attaining that minimum, maximize the number of subarrays. Return that maximum count.

Source: Split Array Into Maximum Number of Subarrays on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [1,0,2,0,1,2]
Output
3

# Example 2

Input
nums = [5,7,1,3]
Output
1

Constraints

1 <= nums.length <= 10^5
0 <= nums[i] <= 10^6

Related LeetCode Problems

Practice more problems similar to Split Array Into Maximum Number of Subarrays.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.