1293. Shortest Path in a Grid with Obstacles Elimination

add one more dimension in visited

[x][y]k+1]: 記錄在某座標, 第三維紀錄 使用的消除次數 0~k (boolean

so

再遇到有障礙的座標時, 這樣代表用完了

T: O(mnk) , mn is the be the number of cells in the grid, and K be the quota to eliminate obstacles.

S: O(mnk)

simpler version

shorter version

new version

More consistent way

or ...still check count first... all good

Last updated

Was this helpful?