Given a string s and an array of words, return how many words in the array are subsequences of s. Pattern focus: Distinct subsequences. This is a standard subsequence-counting problem often solved with buckets or DP-inspired matching states.
s = base string, words = list of candidate words
number of words that are subsequences of s
Example 1:
Input:
s = "abcde" words = ["a","bb","acd","ace"]
Output:
3
Explanation:
The subsequences are a, acd, and ace.
Example 2:
Input:
s = "dsahjpjauf" words = ["ahjpjau","ja","ahbwzgqnuk","tnmlanowax"]
Output:
2
Explanation:
Two of the words can be matched as subsequences.