Number of Matching Subsequences
Given stringS
and a dictionary of wordswords
, find the number ofwords[i]
that is a subsequence ofS
.
Note:
All words in
words
and
S
will only consists of lowercase letters.
The length of
S
will be in the range of
[1, 50000]
.
The length of
words
will be in the range of
[1, 5000]
.
The length of
words[i]
will be in the range of
[1, 50]
.
分析
类似Shortest Way to Form String,建立 Inverted index。在index list内就是存在,>= len(charlist)说明不在。同时curidx是在当前source的Pos,每次都要记得更新。
Last updated