792. Number of Matching Subsequences
792. Number of Matching Subsequences
Description
Given a string s and an array of strings words, return the number of words[i] that is a subsequence of s.
A subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters.
- For example,
"ace"is a subsequence of"abcde".
Example 1:
1 | Input: s = "abcde", words = ["a","bb","acd","ace"] |
Example 2:
1 | Input: s = "dsahjpjauf", words = ["ahjpjau","ja","ahbwzgqnuk","tnmlanowax"] |
Constraints:
1 <= s.length <= 5 * 10^41 <= words.length <= 50001 <= words[i].length <= 50sandwords[i]consist of only lowercase English letters.
Hints/Notes
- 2025/02/27 Q2
- next letter pointer
- 0x3Fâs solution
Solution
Language: C++
1 | class Solution { |