How can I determine all possible ways a subsequence can be removed from a sequence?
<p>Given two sequences, <em>A</em> and <em>B</em>, how can I generate a list of all the possible ways that <em>B</em> can be removed from <em>A</em>?</p>

<p>For example, In JavaScript, if I had a function <code>removeSubSeq</code> taking two array arguments that did what I want, it would work as follows:</p>

<p><code>removeSubSeq([1,2,1,3,1,4,4], [1,4,4])</code> would return <code>[ [2,1,3,1], [1,2,3,1], [1,2,1,3] ]</code> because the 4s at the end would match, and there are three possible places for the 1 to match</p>

<p><code>removeSubSeq([8,6,4,4], [6,4,8])</code> would return <code>[]</code> because the second argument is not actually a subsequence</p>

<p><code>removeSubSeq([1,1,2], [1])</code> would return <code>[ [1,2], [1,2] ]</code> because there's two ways that the 1 could be removed, even though it results in duplicates</p>