Paths in grid with obstacles
A robot starts at the top-left of an m x n grid and wants to reach the bottom-right, moving only right or down. Some cells contain obstacles marked 1 (free cells are 0); the robot cannot enter an obstacle. Return the number of distinct obstacle-free paths. If the start or destination cell is an obstacle, return 0. Dimensions are at least 1x1 and at most 100x100.
Implement
unique_paths_with_obstacles(grid: list[list[int]]) → intExamples
in
[[[0,0,0],[0,1,0],[0,0,0]]]out2What 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 20 min
solution.py
InputExpectedGot
[[[0,0,0],[0,1,0],[0,0,0]]]2not run yetsample