Given a binary array and an integer k, find the position of zeroes flipping which creates maximum number of consecutive 1s in array.

Example 1:

Input: arr = [1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1], m = 2
Output: [5, 7]
Explanation:
We are allowed to flip maximum 2 zeroes. If we flip arr[5] and arr[7], we get 8 consecutive 1's which is
maximum possible under given constraints 

Example 2:

Input: arr = [1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1], m = 1
Output: [7]

Example 3:

Input: arr = [0, 0, 0, 1], m = 4
Output: [0, 1, 2]

Related questions:

Comments (19)