c++ | easy | short
\n# Code\n\nclass Solution {\npublic:\n     int n , m;\n    int dx[4] = {1, 0, -1, 0};\n    int dy[4] = {0, 1, 0, -1};\n\t\n    bool inside(int x, int y) {\n   
\n# Code\n```\nclass Solution {\npublic:\n     int n , m;\n    int dx[4] = {1, 0, -1, 0};\n    int dy[4] = {0, 1, 0, -1};\n\t\n    bool inside(int x, int y) {\n        return (x >= 0 && x < n && y >= 0 && y < m);\n    }\n\n    bool canWalk(int srcX, int srcY, int destX, int destY, vector<vector<char>>&grid, vector<vector<int>>&visited)\n    {\n        if(srcX == destX && srcY == destY) return true;\n        visited[srcX][srcY] = 1;\n        for(int i = 0; i < 4; i++)\n        {\n            int x = srcX + dx[i];\n            int y = srcY + dy[i];\n            if(inside(x, y) && grid[x][y] != \'#\' && !visited[x][y])\n            {\n                if(canWalk(x, y, destX, destY, grid, visited))\n                    return true;\n            }\n        }\n        return false;\n    }\n    int minPushBox(vector<vector<char>>& grid) {\n         n = grid.size();\n         m = grid[0].size();\n         int boxX, boxY, targetX, targetY, personX, personY; \n         for(int i = 0; i < n; i++)\n         {\n             for(int j = 0; j < m; j++)\n             {\n                 if(grid[i][j] == \'S\')\n                 {\n                     personX = i;\n                     personY = j;\n                 }\n                 else if(grid[i][j] == \'T\')\n                 {\n                     targetX = i;\n                     targetY = j;\n                 }\n                 else if(grid[i][j] == \'B\')\n                 {\n                     boxX = i;\n                     boxY = j;\n                 }\n             }\n         }\n\t\t \n         queue<vector<int>>q;\n         set<vector<int>> seen;\n         q.push({boxX, boxY,personX, personY});\n         int ans = 0;\n\t\t \n         while(!q.empty())\n         {\n             int sz = q.size();\n             while(sz--)\n             {\n                auto p = q.front();\n                q.pop();\n                boxX = p[0]; boxY = p[1];\n                personX = p[2]; personY = p[3];\n\t\t\t\t\n                if(boxX == targetX && boxY == targetY)\n                    return ans;\n\t\t\t\t\t\n                grid[boxX][boxY] = \'#\';\n\t\t\t\t\n                for(int i = 0; i < 4; i++)\n                {\n                    int new_boxX = boxX + dx[i];\n                    int new_boxY = boxY + dy[i];\n                    int new_personX = boxX - dx[i];\n                    int new_personY = boxY - dy[i];\n                    vector<int>curPos({new_boxX,new_boxY,new_personX,new_personY});\n                    vector<vector<int>> visited(n, vector<int>(m, 0));\n                    if(inside(new_boxX, new_boxY) && grid[new_boxX][new_boxY]!=\'#\'  && !seen.count(curPos) && canWalk(personX, personY, new_personX, new_personY, grid, visited))\n                    {\n                        seen.insert(curPos);\n                        q.push(curPos);\n                    }\n                }\n                grid[boxX][boxY] = \'.\';\n              }\n             ans++;\n          }\n        return -1;\n    }\n};\n```
['C++']