This problem is a sequel to 62 Unique Paths - so make sure to check that problem out first.
This problem is the same as it’s predecessor, just that there are some obstacles in a grid. We just have to modify the part where if there’s a obstacle at grid[i][j]
we stop our search.
Code
Python3
Big O Analysis
-
Runtime
The runtime complexity here is same as the previous problem. It’s actually but caching makes it linear time.
-
Memory
The memory usage is since we use the
cache
function that uses some dictionary internally for caching/memoising.
— A