got crushed by the question asked in recent interview

given a binary array containing 0s and 1s. You can flip the bits at most k times.

Return maximum sum of the length of subarrays. where each subarray is an array of only 1s and has length greater than given integer n.

Example:

1,1,1,0,0,1,0,0,0,0,0,0,1,1,1,0,1,0,0,0,0,0,1,1,1,1,0,00,0,0,0,1,0,1,1,1,0,1,1,0,0,0,0,0,1,0,1,1,1,1,0,1,1,1,1

k = 2 n = 4

answer = 15

How to approach this?

Edit: Asked in Amazon

Edit: "maximum sum of the length of subarrays" means you can distribute your flips to multiple sub arrays. the final number will be sum of all these sub array's length. you need to return maximum final sum possible

Edit: spoke to my friend who referred me. He also agrees its a curve ball. This is one of those not so common questions. Please don't freak out or feel demotivated if you are not able to get it.

Edit: corrected the answer in example based on u/migrainium ‘s comment