1703. Minimum Adjacent Swaps for K Consecutive Ones
You are given an integer array, nums, and an integer k. nums comprises of only 0’s and 1’s. In one move, you can choose two adjacent indices and swap their values.
Return the minimum number of moves required so that nums has k consecutive 1’s.
c++
1 | class Solution { |