Created
October 30, 2013 13:59
-
-
Save jooyunghan/7233143 to your computer and use it in GitHub Desktop.
trie initial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
unordered_map이 있으니 약간 사기성으 짙으네..