2024-08-02
2134. Minimum Swaps to Group All 1's Together II
A swap is defined as taking two distinct positions in an array and swapping
the values in them.
A circular array is defined as an array where we consider the first element
and the last element to be adjacent.
Given a binary circular array nums, return the minimum number of swaps
required to group all 1's present in the array together at any location.
泥板只剩我不看解答不会写了
题目没有要求要实际换出来
只要计算需要交换的数量
所以就是找一坨1最大坨的地方当最终目标
然后看里面有几个0需要被丢出去换1进来
话说都是1是要开斗剑大会ㄇ?