Count Prefixes of a Given String LeetCode solution in C++

1
class Solution {
2
public:
3
int countPrefixes(vector<string> &words, string s) {
4
int res = words.size();
5

6
for (auto &&word : words) {
7
for (int i = 0; i < word.size(); i++) {
8
if (s[i] != word[i]) {
9
res--;
10
break;
11
}
12
}
13
}
14
return res;
15
}
16
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0