Trains the technique from
LeetCode 792Number of Matching SubsequencesThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A tape reads s, and a list of labels is given as words.
A label reads through the tape when its characters can be found on the tape in order, though not necessarily next to each other.
Return how many of the labels read through the tape, counting a label once for each time it appears in the list.
Example 1
Four of the six read through: "abc", "acb", "bcd" and "cba" can each be found in order along the tape. The label "abcd" cannot, and "zz" has no letters on the tape at all.
Example 2
The same label appears three times and each occurrence counts.
Example 3
The tape holds only one a, so a label needing two cannot read through.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def num_matching_subseq(s: str, words: list[str]) -> int:public int numMatchingSubseq(String s, String[] words)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.