Dijkstra solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n    def minPushBox(self, grid: List[List[str]]) -> int:\n        direction=[[1,0],[-1,0],[0,1],[0,-1]]\n        def dijkstra(start,end,box):\n            if end[0]<0 or end[0]>=len(grid) or end[1]<0 or end[1]>=len(grid[0]) or grid[end[0]][end[1]]=="#":\n                return False\n            heap=[(0,start[0],start[1])]\n            visited={(start[0],start[1]):0}\n            while heap:\n                k,i,j=heappop(heap)\n                if [i,j]==end:\n                    return True\n                if visited[(i,j)]==k:\n                    for q,p in direction:\n                        q+=i\n                        p+=j\n                        if 0<=q<len(grid) and 0<=p<len(grid[0]) and grid[q][p]!="#" and [q,p]!=box:\n                            if (q,p) not in visited or k+1<visited[(q,p)]:\n                                visited[(q,p)]=k+1\n                                heappush(heap,(k+1,q,p))\n            return False\n\n\n        for i in range(len(grid)):\n            for j in range(len(grid[0])):\n                if grid[i][j]=="#" or grid[i][j]==".":\n                    continue\n                elif grid[i][j]==\'S\':\n                    start=[i,j]\n                elif grid[i][j]==\'B\':\n                    box=[i,j]\n                elif grid[i][j]==\'T\':\n                    end=[i,j]\n\n        heap=[(0,box[0],box[1],start[0],start[1])]\n        visit={(box[0],box[1],start[0],start[1]):0}\n        while heap:\n            k,i,j,s,t=heappop(heap)\n            if [i,j]==end:\n                return k\n            if visit[(i,j,s,t)]==k:\n                for q,p in direction:\n                    u=i+q\n                    v=j+p\n                    if 0<=u<len(grid) and 0<=v<len(grid[0]) and grid[u][v]!="#":\n                        if dijkstra([s,t],[i-q,j-p],[i,j]):\n                            if (u,v,i,j) not in visit or k+1<visit[(u,v,i,j)]:\n                                visit[(u,v,i,j)]=k+1\n                                heappush(heap,(k+1,u,v,i,j))\n                        \n\n        return -1\n            \n\n```
['Python3']