1151. Minimum Swaps to Group All 1's Together
https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together
Description
Given a binary array data
, return the minimum number of swaps required to group all 1
’s present in the array together in any place in the array.
Example 1:
Example 2:
Example 3:
Example 4:
Constraints:
1 <= data.length <= 105
data[i]
is0
or1
.
ac
Previous1150. Check If a Number Is Majority Element in a Sorted ArrayNext1152. Analyze User Website Visit Pattern
Last updated