方法一:
字符流:
class Solution {
public:
vector<string> findOcurrences(string text, string first, string second) {
string str;
vector<string> temp,ans;
istringstream word(text);
while(word>>str){
temp.push_back(str);
}
for(int i=0;i<temp.size()-2;i++){
if(temp[i]==first&&temp[i+1]==second){
ans.push_back(temp[i+2]);
}
}
return ans;
}
};
方法二: