2134. Minimum Swaps to Group All 1's Together II
## 思路
fixed size sliding window
size = 陣列裡面1的個數
swap次數 = window裡面0的個數
因為是circular 掃兩次陣列讓頭尾相接
## Complexity
Time: O(N)
Space: O(1)
## Code
```python
class Solution:
def minSwaps(self, nums: List[int]) -> int:
ones = sum(nums)
n = len(nums)
ans = count = sum(nums[i] == 0 for i in range(ones))
for i in range(ones, 2 * n):
count -= (nums[(i-ones) % n] == 0)
count += (nums[i % n] == 0)
ans = min(ans, count)
return ans
```