Trie is an efficient information retrieval data structure. Use this data structure to store Strings and search strings. Your task is to use TRIE data structure and search the given string A. If found print 1 else 0.
Here is simple approach with using a vector to apply stl search function to give true or false return value.
It is execution Time is 0.01s.
#include <bits/stdc++.h>
using namespace std;
int main() {
//code
int t;
cin>>t;
while(t--)
{
string s;
int n;
cin>>n;
vectorv;
for(int i=0;i{
cin>>s;
v.push_back(s);
}
cin>>s;
if(find(v.begin(),v.end(),s)!=v.end())
cout<<1 endl="" p=""> else
cout<<0 endl="" p="">
}
return 0;
}0>1>