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
|
29 Discussions
|
Please Login in order to post a comment
I don't understand this test.
I am failing at
Because it expect me to output
d
but why ? there is nothing prefixingd
becaused
and the first fail isdbeedfdjaghbhgdhcedcj
becaused
prefixdbeedfdjaghbhgdhcedcj
but somehow they want d ? can someone explain cause it s very badly putIf you expect the first thing that caused the failure then should the exemple aab aac aacghgh aabghgh
be aab ?
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