Did you read the top post?
In this version we are looking for subsequences, not substrings.
This is the template with tests:
In this version we are looking for subsequences, not substrings.
Quote:Extend this to instead give an algorithm that finds the number of times one string occurs as a subsequence in another string.I gave a couple sample input/outputs in the OP as well and Grib put them in unittests for convenience.
Whereas a substring must be contiguous, a subsequence need not be, though it must still be in the correct order.
For example if we count occurrences of the subsequence "an" in "banana" we get 3.
Comprised of the following: "banana", "banana", "banana"
This is the template with tests: