We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- No Prefix Set
- Discussions
No Prefix Set
No Prefix Set
Sort by
recency
|
28 Discussions
|
Please Login in order to post a comment
trie with python:
Hewre is a C# solution that uses a simple implementation of a trie using Dictionaries. Passes all test cases:
C++ with std::set instead of trie.
std::set maintains sorted order. For each word, we find the position where it would go in the set (using set::lower_bound), and check its two neighbors. If the left neighbor is a prefix of the word, or the word is a prefix of the right neighbor, it's a bad set, and the current word is the offending word. Otherwise we insert at the position we found and continue.
C++ with Trie
Why the official answer of "Test Case 1" is "d" ? There is no exactly another "d" in the input words as its prefix.
My answer of "Test Case 1" is "ebechbfhfcijcjbcehbgbdgbh" because word, "e", is its prefix.