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
|
230 Discussions
|
Please Login in order to post a comment
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.
after looking at the discussions i get that the question is looking for a Trie implementation. but i just can't see how the following solution doesn't work for all the test cases, because as far as i can see it satisfies every requirement in the question:
I have an issue with the problem description, as it is tailored to a specific solution. Not only having to print "the string being checked" instead of specifically the prefix or string that contains the prefix is inconsistent, but correct answers are marked as wrong. For example, in the test case they show:
4 aab aac aacghgh aabghgh
there are actually FOUR correct answers: aab is a prefix of aabghgh and aac is a prefix of aacghgh. Since we can print any string of the prefix-prefixed pair, we could technically print any of these and be correct. HOWEVER, only BAD SET aacghgh is correct, because they assume we will be solving the problem in a specific way.
Good problem but bad solution criteria, in my opinion.