TITLE: How many Binary Strings of length N contain within it the substring '11011'?
QUESTION [7 upvotes]: I've been trying this for a long time. An example is: 
N = 5. 
Then we can have 11011 which is only one substring. 
But if N = 9, 
We can have many binary strings in the form 
11011xxxx 2^4 combinations
x11011xxx 2^4 combinations
xx11011xx 2^4 combinations
xxx11011x 2^4 combinations
xxxx11011 2^4 combinations
But this is the case of overcounting. (110110110) is one string, but is counted as 2. 
How do we avoid this? 
Note: this question came in the 2016 ZIO.
ZIO2016

REPLY [2 votes]: Let $k$ be the number of blocks of 11011, let $j$ be the number of single overlaps of the blocks (giving $110111011$), and let $l$ be the number of double overlaps (giving $11011011$).
Then there are $\binom{k-1}{j}$ ways to choose the single overlaps, $\binom{k-1-j}{l}$ ways to choose the double overlaps,
$\binom{n-4k+l}{k-j-l}$ ways to choose the positions of the blocks (since there are $k-j-l$ dividers  
and $n-5k+j+2l$ remaining digits), and $2^{n-5k+j+2l}$ ways to choose the other digits.
Using Inclusion-Exclusion, this gives $$\sum_{k=1}^{\lfloor\frac{n-2}{3}\rfloor}(-1)^{k+1}\sum_{j=0}^{k-1}\sum_{l=0}^{k-1-j}\binom{k-1}{j}\binom{k-1-j}{l}\binom{n-4k+l}{k-j-l}2^{n-5k+j+2l}$$.