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