Search a string in the dictionary with a given prefix and suffix for Q queries

  #include using namespace std;  struct Trie {    Trie* arr[27] = { NULL };              int idx;};  Trie* root = new Trie();  void insert(string word, int i){            Trie* temp = root;              for (char ch : word) {                          if (temp->arr[ch – ‘a’] == NULL) {            Trie* t = new Trie();            temp->arr[ch – ‘a’] = t;        }          temp = temp->arr[ch – ‘a’];        temp->idx = i;    }}  int search(string word){    Trie* temp = root;              for (char ch : word) {                                  if (temp->arr[ch – ‘a’] == NULL)            return -1;        temp = temp->arr[ch – ‘a’];    }          return temp->idx;}  void findMatchingString(    string words[], int n,    vector Q){    string temp, t;          for (int i = 0; i < n; i++) {                                  temp = "{" + words[i];          for (int j = words[i].size() - 1;             j >= 0; j–) {            t = words[i][j] + temp;            temp = t;                          insert(t, i);        }    }          for (int i = 0; i < Q.size(); i++) {          string prefix = Q[i][0];        string suffix = Q[i][1];        string temp = suffix + "{" + prefix;                          int res;                          res = search(temp);                          if (res != -1) {            cout