Question
A robot starts at the top-left (0,0) of a grid and must reach the bottom-right corner, moving up/down/left/right through open cells only (grid value 0; value 1 is a wall). Continuing straight is free, but each 90-degree turn costs one. The robot may choose any initial direction for free. Return the minimum number of turns, or -1 if the destination is unreachable or either corner is a wall. Constraints: 1 <= rows, cols <= 100.
min_direction_changes(grid: list[list[int]]) → int[[[0,0,0]]]out0State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.