Skip to content

Commit

Permalink
Time: 117 ms (19.58%), Space: 36.2 MB (93.50%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
Dipendra-Raghav committed Mar 17, 2023
1 parent 8c825cc commit 9468815
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
class Trie {
public:

unordered_map<string,int>mpp,mp;
Trie() {

}

void insert(string word) {
mpp[word]++;
string s;
for(auto it : word)
{
s.push_back(it);
if(mp[s]==0) mp[s]++;
}
}

bool search(string word) {
if(mpp[word]) return true;
return false;
}

bool startsWith(string prefix) {
if(mp[prefix]) return true;
return false;
}
};

0 comments on commit 9468815

Please sign in to comment.