1151. Minimum Swaps to Group All 1's Together (M)

Solution:

https://www.youtube.com/watch?v=9bjARZU5lvI https://www.geeksforgeeks.org/minimum-swaps-required-group-1s-together/ 先计算出有M个1, 然后维护一个size = M的sliding window. 每一个划过去去找在这个Window里面最少要swap多少次

Last updated

Was this helpful?