Link: https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together-ii/
Solution:
Topics: sliding window
Intuition
This is essentially the same problem as Minimum swaps to group all 1s together except for the fact that the first are last element are adjacent, so the idea here is to employ 2 passes by wrapping around the array, no extra memory is required.
Implementation
Review 1
Same as Minimum swaps to group all 1s together