We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d945220 commit f1caa49Copy full SHA for f1caa49
scripts/algorithms/C/Count Prefixes of a Given String/Count Prefixes of a Given String.cpp
@@ -1,15 +1,16 @@
1
+// Runtime: 15 ms (Top 52.29%) | Memory: 11.9 MB (Top 92.97%)
2
class Solution {
3
public:
4
//iterate over each words[i] and take the sub-string str from s of size equals to words[i].
5
//and compare str with words[i] if both are equal increase count by 1.
- int countPrefixes(vector<string>& words, string s)
6
+ int countPrefixes(vector<string>& words, string s)
7
{
8
int count=0;
9
for(auto it: words)
10
11
string str = s.substr(0, it.size());
- if(str == it) count++;
12
+ if(str == it) count++;
13
}
- return count;
14
+ return count;
15
-};
16
+};
0 commit comments