Skip to content

Bug Report for matrixBFS #5949

Description

@i2004-b

Bug Report for https://neetcode.io/problems/matrixBFS

Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.

The problem does not test whether or not the initial top, leftmost location is a 1. In this case, you would need to return -1.

I made the following test case, and the solution code provided output a 6 rather than -1:
grid=[[1, 0, 0, 0],[0, 0, 0, 0],[0, 1, 0, 1],[0, 1, 0, 0]]

The only change that needs to be made to the code is adding a conditional that checks that the starting location is not blocked before adding (0,0) to the queue and the set.

Image Image

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