精華區beta Marginalman 關於我們 聯絡資訊
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是要開鬥劍大會ㄇ? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 73.173.211.221 (美國) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1722570249.A.4B0.html
Smallsh: 大師 08/02 11:44
dont: 大師 08/02 14:56