Robot minimum turns
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.
Implement
min_direction_changes(grid: list[list[int]]) → intExamples
in
[[[0,0,0]]]out0What a strong answer looks like
State 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.
0:00 of about 40 min
solution.py
InputExpectedGot
[[[0,0,0]]]0not run yetsample