for english version: https://dev.to/yunshu67/intro-to-sliding-window-o56
This technique shows how a nested for loop in some problems can be converted to a single for loop to reduce the time complexity.
You are given an integer array
nums, and an integer
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
k consecutive 1's.