Solving Minimum Number of K Consecutive Bit Flips in go. Please try yourself first to solve the problem and submit your implementation to LeetCode before looking into solution.

## Problem Description

Example 1:

``````Input: A = [0,1,0], K = 1
Output: 2
Explanation: Flip A, then flip A.``````

Example 2:

``````Input: A = [1,1,0], K = 2
Output: -1
Explanation: No matter how we flip subarrays of size 2, we can't make the array become [1,1,1].``````

Example 3:

``````Input: A = [0,0,0,1,0,1,1,0], K = 3
Output: 3
Explanation:
Flip A,A,A: A becomes [1,1,1,1,0,1,1,0]
Flip A,A,A: A becomes [1,1,1,1,1,0,0,0]
Flip A,A,A: A becomes [1,1,1,1,1,1,1,1]``````

Note:

1. `1 <= K <= A.length`

2. 1 <= A.length <= 30000

3. 1 <= K <= A.length

`````` A = [0 0 0 1 0 1 1 0] K = 3

A = [2 0 0 1 0 1 1 0] i = 0 flippedTime = 1
A = [2 0 0 1 0 1 1 0] i = 1 flippedTime = 1
A = [2 0 0 1 0 1 1 0] i = 2 flippedTime = 1
A = [2 0 0 1 0 1 1 0] i = 3 flippedTime = 0
A = [2 0 0 1 2 1 1 0] i = 4 flippedTime = 1
A = [2 0 0 1 2 2 1 0] i = 5 flippedTime = 2
A = [2 0 0 1 2 2 1 0] i = 6 flippedTime = 2
A = [2 0 0 1 2 2 1 0] i = 7 flippedTime = 1``````

See the full details of the problem Minimum Number of K Consecutive Bit Flips at LeetCode

Originally posted at: @github.com/halfrost/LeetCode-Go