Java | BFS + BFS
\nclass Solution {\n                                    // Up,    Right,   Bottom  & Left\n    private int[][] dir = new int[][]{{0, 1}, {1, 0}, {0, -1}, {-1, 0
```\nclass Solution {\n                                    // Up,    Right,   Bottom  & Left\n    private int[][] dir = new int[][]{{0, 1}, {1, 0}, {0, -1}, {-1, 0}};\n    \n    public int minPushBox(char[][] grid) {\n        int step = 0;\n        int m = grid.length;\n        int n = grid[0].length;\n        Queue<int[]> q = new LinkedList<>();\n        int[] box,target,player;\n        box = target = player = null;\n        \n        // TO Store Already Processed Node.\n        // Box coordinates with respect to Player\'s Moves\n        boolean[][][] visited = new boolean[m][n][4];\n\n        for (int i = 0; i < m; i++) {\n            for (int j = 0; j < n; j++) {\n                if (grid[i][j] == \'B\') box = new int[]{i, j};\n                else if (grid[i][j] == \'T\') target = new int[]{i, j};\n                else if (grid[i][j] == \'S\') player = new int[]{i, j};\n            }\n        }\n        \n        q.offer(new int[]{box[0], box[1], player[0], player[1]});\n        while (!q.isEmpty()) {\n            int size = q.size();\n            // Process Each Level Nodes of Queue\n            while(size!=0) {\n                int[] curr = q.poll();\n                // Box reached Target Location Return steps...\n                if (curr[0] == target[0] && curr[1] == target[1]) \n                    return step;\n                // Explore 4 directions at this point ...\n                for (int j = 0; j < dir.length; j++) {\n                    \n                    if (visited[curr[0]][curr[1]][j]) \n                        continue;\n                    \n                    int[] d = dir[j];\n                    \n                    int r0 = curr[0] + d[0];\n                    int c0 = curr[1] + d[1];  \n                    int r = curr[0] - d[0];\n                    int c = curr[1] - d[1];\n                    if (!isValid(r0,c0,grid) || !isValid(r,c,grid)) \n                        continue;\n                    if (!isReachable(r0, c0, curr, grid)) \n                        continue;\n                    \n                    visited[curr[0]][curr[1]][j] = true;\n                    q.offer(new int[]{r, c, curr[0], curr[1]});\n                }\n                size--;\n            }\n            step++;\n        }\n        return -1;\n        \n    }\n    \n    // can player reach a position to push ?\n    private boolean isReachable(int x, int y, int[] curr, char[][] grid) {\n        int m = grid.length;\n        int n = grid[0].length;\n        Queue<int[]> q = new LinkedList<>();\n        int playerStartR = curr[2];\n        int playerStartC = curr[3];\n        q.offer(new int[]{playerStartR, playerStartC});\n        boolean[][] visited = new boolean[m][n];\n        // mark the box current position as visited // [0:1] ==> Box Pos\n        visited[curr[0]][curr[1]] = true;\n        while (!q.isEmpty()) {\n            int[] temp = q.poll();\n            if (temp[0] == x && temp[1] == y) \n                return true;\n            for (int[] d : dir) {\n                int r = temp[0] + d[0];\n                int c = temp[1] + d[1];  \n                if (!isValid(r,c,grid) || visited[r][c]) \n                    continue;\n                visited[r][c] = true;\n                q.offer(new int[]{r, c});\n            }\n        }\n        return false;\n    }\n    \n    private boolean isValid(int x, int y,char[][] grid){\n        int r = grid.length;\n        int c = grid[0].length;\n        return x>=0 && x<r && y>=0 && y<c && grid[x][y] != \'#\';\n    }\n    \n}\n```
[]