Bug Report: Incorrect BFS Early Return in WordDictionary Search
Problem: [Design Word Search Data Structure](https://neetcode.io/problems/design-word-search-data-structure)
Bug Description
The current test suite allows an incorrect BFS implementation to pass because it does not test multiple wildcard paths where one path fails and another succeeds.
Buggy code:
if (i === word.length) return node.end == true; — this can return false before processing remaining BFS paths.
Reproduce with:
["WordDictionary","addWord","addWord","search"] / [[],["badly"],["cat"],[".a."]].
Expected output: [null,null,null,true],
but the buggy implementation returns [null,null,null,false].
Please add this test case to ensure BFS continues searching when a completed path is not a valid word.
Bug Report: Incorrect BFS Early Return in WordDictionary Search
Problem: [Design Word Search Data Structure](https://neetcode.io/problems/design-word-search-data-structure)
Bug Description
The current test suite allows an incorrect BFS implementation to pass because it does not test multiple wildcard paths where one path fails and another succeeds.
Buggy code:
if (i === word.length) return node.end == true;— this can returnfalsebefore processing remaining BFS paths.Reproduce with:
["WordDictionary","addWord","addWord","search"]/[[],["badly"],["cat"],[".a."]].Expected output:
[null,null,null,true],but the buggy implementation returns
[null,null,null,false].Please add this test case to ensure BFS continues searching when a completed path is not a valid word.