Tap here to switch tabs
Problem
Submissions

Problem: Split Array Into Maximum Number of Subarrays

med
30 min
Try to solve the Split Array Into Maximum Number of Subarrays problem.

Statement

You are given an array nums of nonnegative integers.

The score of a subarray is defined as the bitwise AND of all its elements. The total score of a split of nums into one or more contiguous subarrays is the sum of the scores of all the subarrays.

Determine the maximum number of contiguous subarrays that nums can be split into such that the total score is minimized.

Note: A subarray is a contiguous sequence of elements within an array.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 0≤0 \leq nums[i] ≤106\leq 10^6

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Split Array Into Maximum Number of Subarrays

med
30 min
Try to solve the Split Array Into Maximum Number of Subarrays problem.

Statement

You are given an array nums of nonnegative integers.

The score of a subarray is defined as the bitwise AND of all its elements. The total score of a split of nums into one or more contiguous subarrays is the sum of the scores of all the subarrays.

Determine the maximum number of contiguous subarrays that nums can be split into such that the total score is minimized.

Note: A subarray is a contiguous sequence of elements within an array.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 0≤0 \leq nums[i] ≤106\leq 10^6