AI Interview Prep is optimized for larger screens
Please open this on a laptop or desktop (1024px and wider) to use the full editor, whiteboard, and AI coaching surface.
Understand the problem
Restate the problem precisely. Interviewers reward candidates who pause, define the contract, and name the guarantees before coding.
Given an `n × n` binary matrix `grid`, return the length of the shortest **clear path** in the matrix. If there is no clear path, return `-1`. A clear path in a binary matrix is a path from the top-left cell `(0, 0)` to the bottom-right cell `(n - 1, n - 1)` such that all the visited cells of the path are `0`, and all the adjacent cells of the path are 8-directionally connected (i.e., they are different and they share an edge or a corner). The length of a clear path is the number of visited cells of this path.
Once you've drafted a response, click Submit for AI review and a senior engineer will critique your reasoning.