1151. Minimum Swaps to Group All 1's Together (M)
Previous1438. Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit (M)Next2134. Minimum Swaps to Group All 1's Together II
Last updated
Was this helpful?
Last updated
Was this helpful?
Solution:
先计算出有M个1, 然后维护一个size = M的sliding window. 每一个划过去去找在这个Window里面最少要swap多少次