Question
On an m x n grid, cells are marked: 1 is the start (exactly one), 2 is the destination (exactly one), 0 is an empty cell you must walk over, and -1 is an obstacle to avoid. Starting at 1 and moving up/down/left/right, return the number of distinct 4-directional paths from start to destination that visit every non-obstacle cell exactly once. The grid is at most 5x5 (so it has at most 20 walkable cells). Return an integer.
unique_paths_iii(grid: list[list[int]]) → int[[[1,0,0,0],[0,0,0,0],[0,0,2,-1]]]out2State 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.