Skip to content

Bug Report for design-word-search-data-structure #6100

Description

@ankitsharma9122

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions