Skip to content

Commit 7acd19d

Browse files
Added solution
1 parent 5a333e8 commit 7acd19d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

occurrences_in_bigrams.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Solution {
2+
public:
3+
vector<string> findOcurrences(string text, string first, string second) {
4+
5+
string F = "", S = "";
6+
string word;
7+
vector<string> ans;
8+
9+
for(char c : text){
10+
if(c == ' '){
11+
if(F == first && S == second) ans.push_back(word);
12+
F = S;
13+
S = word;
14+
word.clear();
15+
}
16+
else
17+
word.push_back(c);
18+
}
19+
if(F == first && S == second) ans.push_back(word);
20+
return ans;
21+
}
22+
};

0 commit comments

Comments
 (0)