Leetcode-5083 Occurrences After Bigram(Bigram 分词)
作者:互联网
1 #define _for(i,a,b) for(int i = (a);i < b;i ++) 2 3 class Solution 4 { 5 public: 6 vector<string> findOcurrences(string text, string first, string second) 7 { 8 vector<string> rnt; 9 vector<string> li; 10 string tmp; 11 int i = 0; 12 while(i < text.size()) 13 { 14 while(text[i] != ' ' && i < text.size()) 15 { 16 tmp += text[i]; 17 i ++; 18 } 19 i ++; 20 li.push_back(tmp); 21 tmp.clear(); 22 } 23 _for(j,0,li.size()) 24 { 25 if(li[j]==first && j+1 < li.size() && li[j+1]==second) 26 { 27 if(j+2<li.size()) 28 rnt.push_back(li[j+2]); 29 } 30 } 31 return rnt; 32 } 33 };
标签:tmp,Bigram,string,5083,text,After,li,&&,size 来源: https://www.cnblogs.com/Asurudo/p/10993162.html