Skip to content

Instantly share code, notes, and snippets.

@ldct
Created January 13, 2016 13:29
Show Gist options
  • Save ldct/fc2b88c4455ddfddb723 to your computer and use it in GitHub Desktop.
Save ldct/fc2b88c4455ddfddb723 to your computer and use it in GitHub Desktop.
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