Search⌘ K
AI Features

Solution: Shortest Path in Binary Matrix

C# solution for the Shortest Path in Binary Matrix problem using the Graphs pattern.

Statement

Given a square binary matrix grid of size n x n, find the length of the shortest clear path from the top left cell to the bottom right cell.

A clear path is a sequence of cells such that every visited cell has value 00. The path starts at grid[0][0] and ends at grid[n-1][n-1]. Return the number of cells in the shortest such path. If no clear path exists, return ...