Tap here to switch tabs
Problem
Submissions

Problem: All Divisions With the Highest Score of a Binary Array

Try to solve the All Divisions With the Highest Score of a Binary Array problem.

Statement

Given a 00 indexed binary array nums of length n.

You can partition nums at any index i (where 0≤0 \leq i ≤\leq n) into two subarrays:

  • nums_left, which contains elements from index 00 to i −1- 1 (empty if i =0= 0).

  • nums_right, which contains elements from index i to n −1- 1 (empty if i == n).

The division score at index i is defined as the sum of:

  • The number of 00s in nums_left.

  • The number of 11s in nums_right.

Return all distinct indices i that yield the highest possible division score. You may return the indices in any order.

Note: The returned indices can be presented in any order.

Constraints:

  • n ==== nums.length

  • 1≤1 \leq n ≤105\leq 10^5

  • nums[i] is either 00 or 11.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: All Divisions With the Highest Score of a Binary Array

Try to solve the All Divisions With the Highest Score of a Binary Array problem.

Statement

Given a 00 indexed binary array nums of length n.

You can partition nums at any index i (where 0≤0 \leq i ≤\leq n) into two subarrays:

  • nums_left, which contains elements from index 00 to i −1- 1 (empty if i =0= 0).

  • nums_right, which contains elements from index i to n −1- 1 (empty if i == n).

The division score at index i is defined as the sum of:

  • The number of 00s in nums_left.

  • The number of 11s in nums_right.

Return all distinct indices i that yield the highest possible division score. You may return the indices in any order.

Note: The returned indices can be presented in any order.

Constraints:

  • n ==== nums.length

  • 1≤1 \leq n ≤105\leq 10^5

  • nums[i] is either 00 or 11.