网站首页
编程语言
数据库
系统相关
其他分享
编程问答
次破墙
2024-10-02
[Python手撕]网格中的最短路径(可以有k次破墙的机会)
classSolution:defshortestPath(self,grid:List[List[int]],k:int)->int:n=len(grid)m=len(grid[0])ifm==n==1:return0direction=[[0,1],[-1,0],[1,0],[0,-1]]visited=[[[