Created
January 13, 2016 13:29
-
-
Save ldct/fc2b88c4455ddfddb723 to your computer and use it in GitHub Desktop.
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 PrefixStringSet { | |
public: | |
map<char, *PrefixStringSet> m; | |
bool contains(string s) { | |
cout << "contains " << s << endl; | |
if (s.size() == 0) { | |
return true; | |
} | |
if (m.find(s[0]) == m.end()) { | |
return false; | |
} | |
return m[s[0]]->contains(s.substr(1)); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment