Skip to content

Bug Report for matrixBFS #3964

Open
Open
@hsiwkin

Description

@hsiwkin

Bug Report for [Matrix BFS Problem on NeetCode.io](https://neetcode.io/problems/matrixBFS)

Issue

The initial element of the provided grid (grid[0][0]) is NaN when executing JavaScript code.

Observed Behavior

Executing the JavaScript code snippet below results in the grid's first element becoming NaN:

class Solution {
    /**
     * @param {number[][]} grid
     * @returns {number}
     */
    shortestPath(grid) {
        console.log(grid);
    }
}

Output:

[
  [ NaN, 0, 0, 0 ],
  [ 1, 1, 0, 0 ],
  [ 0, 0, 0, 1 ],
  [ 0, 1, 0, 0 ]
]

Expected Behavior

The grid provided should contain valid numeric values (0 or 1) without any NaN values.

Steps to Reproduce

  1. Visit the [Matrix BFS problem page](https://neetcode.io/problems/matrixBFS).
  2. Paste the JavaScript snippet provided above into the solution editor.
  3. Execute the code and observe the output.

Environment

  • Browser: Chrome Version 134.0.6998.119
  • Operating System: MacOS Sequoia 15.3.2 (24D81)
  • Platform: JavaScript playground on Neetcode.io

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