How many substrings of length m can be formed from a string of length n?
Simple counting problem but can't wrap my head around it
ABCD -- Substrings of length 2 : AB, BC, CD. Similarly ABCDE and length 3 -- ABC, BCD, CDE
I see m choose n won't work -- we'll get all subsequences too
Solution 1:
Consider how many of the characters in the string are valid "starting characters" for the substrings you desire. For instance, in "ABCD," only "A", "B", and "C" are valid starting characters for substrings of length 2.
In general, in a string of length $n$, if you want a substring of length $m$, you can only choose the first $n - m + 1$ characters as starting characters.