Min K Consecutive Bit Flips

You are given a binary array nums (0s and 1s) and an integer k. In one operation, pick any subarray of length k and flip all its bits. Return the minimum number of flips to make all elements 1, or -1 if impossible.

Examples
Input: [[0,1,0],1]
Output: 2
Hints

Min K Consecutive Bit Flips

You are given a binary array nums (0s and 1s) and an integer k. In one operation, pick any subarray of length k and flip all its bits. Return the minimum number of flips to make all elements 1, or -1 if impossible.