Grokking Data Structures & Algorithms for Coding Interviews
Ask Author
Back to course home

0% completed

Vote For New Content
Em Eff
Code in solution doesn't pass all test cases in the challenge

Em Eff

Mar 15, 2025

Specifically, submitting my solution fails following test case is fails, even when copying the solution into the challenge verbatim:

Your Input ["mobile","mouse","moneypot","monitor","mousepad"] "mouse"
Output [["mobile","mouse","mousepad"],["mobile","mouse","mousepad"],["mouse","mousepad"],["mouse","mousepad"],["mouse","mousepad"]]
Expected [["mobile","moneypot","monitor"],["mobile","moneypot","monitor"],["mouse","mousepad"],["mouse","mousepad"],["mouse","mousepad"]]

This is actually very confusing because running my solution (instead of submitting) gives a different expected output for the same input mentioned above:

Expected [["mobile","mouse","mousepad"],["mobile","mouse","mousepad"],["mouse","mousepad"],["mouse","mousepad"],["mouse","mousepad"]]

It seems that the test case isn't actually looking for results in lexicographical order because, unless I'm mistaken, "monitor" should come before "mousepad", yet the test case doesn't reflect that.

Overall, I don't understand how this solution even works since the TrieNode's children is an object, and there appears to be no logic in place to ensure that they are traversed in alphabetical order.

0

0

Comments
Comments

On this page