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
|
232 Discussions
|
Please Login in order to post a comment
C++17 code for your reference:
C++11 variant with Trie. As it was pointed out tests want you to implement exactly this solution.
Yes, agree, annoing test for this solution. The solution should not depend on tests. The most straitforward is to sort array and compare string i, and i+1. there is also more optimal solution even without sorting. Unfortunately test case rely on the specific non optimal brute force solution. This is not advance test if you ecourage others on this simplistic unefficicient solution to deal with (n*n)/2 string comparisons!
If you're wondering why your test case doesn't work, it's because the test cases are wrong, not your solution.
They expect you to use a trie but this is not in the instructions, yet the order in which the first bad string appears depends entirely on your solution. The deteciton of any bad string should have been sufficient to solve this problem.
From reading this discussion it seems this is seeing if we used a trie. Even so, this doesn't timeout and I think the logic seems to check out. Given their criteria that words are tested in order, and the prefix 'aab' is lower indexed compared to 'aac'. Guess im skipping this one.