Grid BFS: In a rectangular 0/1 grid, find the minimum number of four-direction moves from the top-left cell to the bottom-right cell. Cells with 1 are blocked; return -1 when unreachable.
Input: A JSON object { "grid": number[][] } containing only 0 and 1.
Output: A JSON integer move count, or -1.
Constraints:
- 0 <= rows, columns <= 500
- The grid is rectangular
- Movement is allowed up, down, left, and right only
Read one JSON value from stdin and print exactly one JSON-serialized answer to stdout with no extra text.
Difficulty: EASY. Variant: 1. Expect follow-up questions about complexity, edge cases, and alternative approaches.
Practice context
This coding (algo) exercise trains prompt interpretation, explicit assumptions, a concrete response, and a concise explanation of the decisions made. It is marked easy difficulty.
The signed-in workspace provides the tools required