题解 | #某云ES倒排索引#
某云ES倒排索引
https://www.nowcoder.com/practice/7ba676741a3c4920b7846476be520779
class Solution { public: vector<int> invertedIndex(vector<int>& ID, vector<string>& content, string word) { // write code here vector<int> ans; for(int i = 0;i<ID.size();i++) { for(int j = 0,k = 0;j<content[i].size();j++) { while(content[i][j]==word[k]) { j++; k++; } if(k>=word.length()) { ans.push_back(ID[i]); break; } else{ k = 0; } } } return ans; } };