Out of all bit strings of length $N$, we need to count how many of them are there in which all the ones are present in a window of length $K$.
For this, my initial thought was:
The starting point of the window can be placed at $(N - K)$ positions. In each window, each bit can either be $1$ or $0$. The number of bit strings would then be $(N - K) * 2^k$.
However, there is over-counting involved in this method.
How do I solve this problem?