-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1078.cpp
More file actions
28 lines (26 loc) · 697 Bytes
/
1078.cpp
File metadata and controls
28 lines (26 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class Solution {
public:
vector<string> findOcurrences(string text, string first, string second) { //O(N)
istringstream stream(text);
string token;
bool prev = false;
bool getThis = false;
vector<string> ans;
while(getline(stream, token, ' ')){
if(getThis){
ans.push_back(token);
}
if(prev && token == second){
getThis = true;
} else{
getThis = false;
}
if(token == first){
prev = true;
} else {
prev = false;
}
}
return ans;
}
};