Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Tuấn Trần
Python test case seems not well organized.

Tuấn Trần

Jan 31, 2024

In python, I think my code works well, but the test cases seem not well organized.

In word match case, the function returns true, but the test code prints "0", instead of "1" in the expected result:

Your Input ["Solution","addWord","addWord","addWord","search","search","search","search"] [[],["apple"],["banana"],["cherry"],["apple"],["ban..a"],["cherr."],["b.n.n."]] Output [-1,-1,-1,-1,0,0,0,0] Expected [-1,-1,-1,-1,1,1,1,1]

2

0

Comments
Comments
J
Jimmy 2 years ago

The expected result should be 1 for the searches as "apple", "ban..a", "cheer.", "b.n.n." all have words in the trie. Your code is returning 0 for all those cases.

L
Lee 2 years ago

I have the same issue. Can't tell if it's my code or the test code it's wrapped in.

On this page