Skip to content

Instantly share code, notes, and snippets.

@jooyunghan
Created October 30, 2013 13:59
Show Gist options
  • Save jooyunghan/7233143 to your computer and use it in GitHub Desktop.
Save jooyunghan/7233143 to your computer and use it in GitHub Desktop.
trie initial
class trie {
int count;
unordered_map<char, trie> children;
int& get(const char* s) {
if (*s == '\0') {
return count;
} else {
return children[*s].get(s+1);
}
}
public:
int& operator[](const string& s) {
return get(s.c_str());
}
};
@jooyunghan
Copy link
Author

unordered_map이 있으니 약간 사기성으 짙으네..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment