Tap here to switch tabs
Problem
Submissions

Problem: Minimum Swaps to Group All 1's Together

med
30 min
Try to solve the Minimum Swaps to Group All 1's Together problem.

Statement

Given a binary array data, return the minimum number of swaps required to group all 11’s present in the array together at any position.

Constraints:

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

  • data[i] is either 00 or 11.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Swaps to Group All 1's Together

med
30 min
Try to solve the Minimum Swaps to Group All 1's Together problem.

Statement

Given a binary array data, return the minimum number of swaps required to group all 11’s present in the array together at any position.

Constraints:

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

  • data[i] is either 00 or 11.