Consider an array of N + 2 binary digits (1 and 0), which contains at least one '1' and three '0'. The last and first digit of the array is 0.
Given two numbers, let's say p and q, determine how many different arrays exist which respect what I've said right above and have all the CONTINUOUS sequences of '1' minimum p and maximum q in length.
This can be solved in O(N) with DP. But how? I just need the recurrence relation explained. Can you help me?
Thank you very much!
LE (example)
N = 5
p = 2, q = 3
The result is 8 and these are the possibilities:
0000110
0001100
0001110
0011000
0011100
0110000
0110110
0111000
Hints:
The run time is $O((q-p)N) = O(N)$ for fixed $p$ and $q$.