题目: LeetCode: 792. Number of Matching Subsequences(https://leetcode.com/problems/number-of-matching-subsequences/description/)
class Solution {
public int numMatchingSubseq(String S, String[] words) {
return (int)Arrays.stream(words)
.filter(word -> {
int currentLoc = 0;
byte[] bytes = word.getBytes();
for(int i =0; i < bytes.length; i++) {
currentLoc = S.indexOf(bytes[i], currentLoc);
if(currentLoc == -1) {
return false;
}
currentLoc++;
}
return true;
})
.count();
}
}