#792
Number of Matching Subsequences
specialist · 860 · lc medium +31 · verified · 50.6% accepted · 5,796 likes · top 39%
Description
Given a string s and an array of strings words, count how many strings in words are subsequences of s.
A subsequence of a string is formed by removing zero or more characters from the original without disturbing the relative order of the remaining characters.
- For instance, "ace" is a subsequence of "abcde".
Example 1:
Input: s = "abcde", words = ["a","bb","acd","ace"]
Output: 3
Explanation: There are three strings in words that are a subsequence of s: "a", "acd", "ace".
Example 2:
Input: s = "dsahjpjauf", words = ["ahjpjau","ja","ahbwzgqnuk","tnmlanowax"]
Output: 2
Code
1
2
3