I have to design an algorithm to do the next task:

I have one array of booleans. For example:

Array: [0 1 0 0 1 0 1 1]

I want to obtain all the existing combinations of 1's, having in mind that it is allowed only a **maximum of one 0 between 1's**.
For example, in the previous case, we would have the outputs (**I am using the indices now**):
[1] and [4,5,6,7].

But also it should include [4], [6], [7], [4,5,6], [6,7].

Another example:

Array: [0 1 0 1 0 1 0 0 1]

The output would be: [1], [3], [5]. [8], [1,2,3], [1,2,3,4,5], [3,4,5].

Can you imagine any approach to solve this? The combination explosion could be quite big.

Thank you very much in advance.