Leetcode-5083 Occurrences After Bigram(Bigram 分词)
Posted asurudo
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 ;
以上是关于Leetcode-5083 Occurrences After Bigram(Bigram 分词)的主要内容,如果未能解决你的问题,请参考以下文章
leetcode1207. Unique Number of Occurrences
Python --- 1078. Occurrences After Bigram 解题报告
Python --- 1078. Occurrences After Bigram 解题报告
Count the number of occurrences in a sorted array