Unique paths grid all cells

Write codeHard35 minGoogle style

Your task

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.

Examples

unique_paths_iii(grid: list[list[int]]) -> int
Example 1
Inputunique_paths_iii([[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 2, -1]])
Output2