Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Trie/iterative_trie.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// C++ implementation of trie
#include <bits/stdc++.h>

using namespace std;
Expand All @@ -11,7 +12,7 @@ int sz = 0;
int next[27][MaxN];
int end[MaxN];
bool created[MaxN];

// insert key into trie
void insert (string &s) {
int v = 0;

Expand All @@ -25,7 +26,7 @@ void insert (string &s) {
}
++end[v];
}

// return true if key present in trie and
bool search (string tmp) {
int v = 0;

Expand All @@ -39,9 +40,11 @@ bool search (string tmp) {
}

int main () {
// keys supports lowercase and uppercase letters
string keys[] = {"hi", "hello", "you", "ekta", "me"};
string output[] = {"NO", "YES"};

// construct trie
for (int i = 0; i < 5; ++i)
insert (keys[i]);

Expand Down