I had thought that the condition is "number of flowers that are not blooming between the two blooming flowers is k", because the level of the question is hard. But I was wrong.

Example

[1,7,5,6,4,3,2,1], k = 5

In the day 3, the status of the flowers is

[1, 0, 0, 0, 0, 1, 0, 1]

So the number of flowers that are not blooming between flower 1 and flower 7 is 5.

The answer will be 3.

But how to solve it if the question is exactly in this way?

Does anybody have an idea?