counting-words-with-a-given-prefix 1.0.0
Counting Words With a Given Prefix
Loading...
Searching...
No Matches
Solution Class Reference

Public Member Functions

int prefixCount (vector< string > &words, string pref)
 

Detailed Description

Definition at line 5 of file main.cpp.

Member Function Documentation

◆ prefixCount()

int Solution::prefixCount ( vector< string > &  words,
string  pref 
)
inline

Definition at line 8 of file main.cpp.

9 {
10 int count = 0;
11 for (string& word: words)
12 {
13 for (int i = 0; i < (int)pref.size(); ++i)
14 {
15 if (pref[i] != word[i])
16 break;
17 else
18 if (i + 1 == (int)pref.size())
19 count++;
20 }
21 }
22 return count;
23 }

Referenced by main().


The documentation for this class was generated from the following file: