Python3 nested BFS (95.82%)
Outer BFS - move box to next place \nInner BFS - check if player can be placed to move box to next place \n\n\nfrom itertools import product\n\nclass Solution:\
Outer BFS - move box to next place \nInner BFS - check if player can be placed to move box to next place \n\n```\nfrom itertools import product\n\nclass Solution:\n    def minPushBox(self, grid: List[List[str]]) -> int:\n        #constants\n        m, n = len(grid), len(grid[0]) #dimensions\n        neighbors = ((-1,0), (1,0), (0,-1), (0,1)) \n        \n        #initial values\n        for i, j in product(range(m), range(n)):\n            if   grid[i][j] == "B": box    = i, j\n            elif grid[i][j] == "S": player = i, j\n            elif grid[i][j] == "T": target = i, j\n        \n        #helper functions\n        not_wall = lambda i, j: 0 <= i < m and 0 <= j < n and grid[i][j] !="#" #true if not wall\n            \n        def connected(s, d):\n            """bfs to check if s and d are connected"""\n            queue = [s]\n            seen = set(queue)\n            for i, j in queue: #okay to change size\n                for di, dj in neighbors:\n                    ii, jj = i + di, j + dj\n                    if not_wall(ii, jj) and (ii, jj) != box and (ii, jj) not in seen: \n                        queue.append((ii, jj))\n                        seen.add((ii, jj))\n                if d in seen: return True\n            return False \n        \n        #logic -- nested bfs \n        final = set((target, (target[0]+di, target[1]+dj)) for di, dj in neighbors)\n        \n        moves = 0 \n        queue = [(box, player)] #initial position\n        seen = set(queue)\n        while queue: #bfs by level \n            temp = []\n            for box, player in queue:\n                i, j = box\n                for di, dj in neighbors:\n                    if not_wall(i+di, j+dj) and ((i+di, j+dj), (i, j)) not in seen and not_wall(i-di, j-dj) and connected(player, (i-di, j-dj)):\n                        temp.append(((i+di, j+dj), (i, j)))\n                        seen.add(((i+di, j+dj), (i, j)))\n            queue = temp\n            moves += 1\n            if seen & final: return moves #final configuration => arrive at target\n        return -1 \n```
['Python3']