Skip to content

Instantly share code, notes, and snippets.

@byron-perez
Last active October 19, 2017 22:01
Show Gist options
  • Save byron-perez/574bee22d7ab2fb5b71c8ea893d7f87e to your computer and use it in GitHub Desktop.
Save byron-perez/574bee22d7ab2fb5b71c8ea893d7f87e to your computer and use it in GitHub Desktop.
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;
struct trieNode
{
struct trieNode* children[26];
bool isEndOfWord;
};
struct trieNode *createNode()
{
struct trieNode *node = new trieNode;
for(int i = 0; i < 26; i++)
{
node->children[i] = NULL;
}
node->isEndOfWord = false;
return node;
}
void addWord(string s, struct trieNode *root)
{
struct trieNode* trv = root;
int n = s.length();
for(int i = 0; i < n; i++)
{
int index = s[i] - 'a';
if(!trv->children[index])
trv->children[index] = createNode();
trv = trv->children[i];
}
trv->isEndOfWord = true;
}
int main(){
int n;
cin >> n;
for(int a0 = 0; a0 < n; a0++){
string op;
string contact;
cin >> op >> contact;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment