My java 8ms solution 87% faster
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```java []\nclass Solution {\n    public int minPushBox(char[][] grid) {\n        int sr = 0, sc = 0;\n        int er = 0, ec = 0, r = 0, c = 0;\n        for(int i = 0; i < grid.length; i++){\n            for(int j = 0; j < grid[0].length; j++){\n                if(grid[i][j] == \'T\'){\n                    er = i;\n                    ec = j;\n                }\n                if(grid[i][j] == \'B\'){\n                    sr = i;\n                    sc = j;\n                }\n                if(grid[i][j] == \'S\'){\n                    r = i;\n                    c = j;\n                }\n            }\n        }\n        boolean[][][][] vis = new boolean[grid.length][grid[0].length][grid.length][grid[0].length];\n        ArrayDeque<int[]> q = new ArrayDeque<>();\n        dfs(r, c, sr, sc, grid, vis, q);\n        grid[sr][sc] = \'.\';\n        int lvl = 1;\n        while(!q.isEmpty()){\n            int size = q.size();\n            for(int i = 0; i < size; i++){\n                int[] curr = q.poll();\n                if(curr[2] == er && curr[3] == ec){\n                    return lvl - 1;\n                }\n                int nextR = curr[2] + curr[4];\n                int nextC = curr[3] + curr[5];\n                if(valid(nextR, nextC, grid)){\n                    curr[0] += curr[4];\n                    curr[1] += curr[5];\n                    curr[2] = nextR;\n                    curr[3] = nextC;\n                }\n                grid[curr[2]][curr[3]] = \'B\'; // putting block in the path and trying all the ways a person can stand near the box\n                dfs(curr[0], curr[1], curr[2], curr[3], grid, vis, q);\n                grid[curr[2]][curr[3]] = \'.\'; // remove block again\n            }\n            lvl++;\n        }\n        return -1;\n    }\n\n    public boolean valid(int r, int c, char[][] grid){\n        if(r < 0 || r == grid.length || c < 0 || c == grid[0].length || grid[r][c] == \'#\'){\n            return false;\n        }\n        return true;\n    }\n\n    public void dfs(int r, int c, int er, int ec, char[][] grid, boolean[][][][] vis, ArrayDeque<int[]> q){\n        if(r < 0 || r == grid.length || c < 0 || c == grid[0].length || grid[r][c] == \'#\' || \n        grid[r][c] == \'B\' || vis[r][c][er][ec]){\n            return;\n        }\n        check(r, c, er, ec, grid, q);\n        vis[r][c][er][ec] = true;\n        dfs(r + 1, c, er, ec, grid, vis, q);\n        dfs(r - 1, c, er, ec, grid, vis, q);\n        dfs(r, c + 1, er, ec, grid, vis, q);\n        dfs(r, c - 1, er, ec, grid, vis, q);\n    }\n\n    public void check(int r, int c, int er, int ec, char[][] grid, ArrayDeque<int[]> q){\n        if(r == er){\n            if(c + 1 == ec){\n                q.offer(new int[]{r, c, er, ec, 0, 1});\n            }else if(c - 1 == ec){\n                q.offer(new int[]{r, c, er, ec, 0, -1});\n            }\n        }else if(c == ec){\n            if(r + 1 == er){\n                q.offer(new int[]{r, c, er, ec, 1, 0});\n            }else if(r - 1 == er){\n                q.offer(new int[]{r, c, er, ec, -1, 0});\n            }\n        }\n    }\n}\n```
['Java']