Question
Each cell of an m x n grid contains an arrow (1=right, 2=left, 3=down, 4=up) giving the default outgoing direction. Starting at the top-left cell you follow arrows for free, but you may change the sign of any single cell once for a cost of 1 (then it keeps that new sign). Return the minimum total cost of modifications needed so that there exists a valid path from the top-left cell to the bottom-right cell.
min_cost_grid_path(grid: list[list[int]]) → int[[[1,1,1,1],[2,2,2,2],[1,1,1,1],[2,2,2,2]]]out3State 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.