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是要開鬥劍大會ㄇ?