C++ | Easy implementation | BFS*BFS | Clean code
\nclass Solution {\npublic:\n     int arr[4]= {0,0,1,-1};\n    int brr[4]={1,-1,0,0};\n    bool chk (vector<vector<char>>& grid, int reachx,int reachy,int bx,in
```\nclass Solution {\npublic:\n     int arr[4]= {0,0,1,-1};\n    int brr[4]={1,-1,0,0};\n    bool chk (vector<vector<char>>& grid, int reachx,int reachy,int bx,int by,int sx,int sy)\n    {\n        \n        int r = grid.size();\n        int c = grid[0].size();\n        vector<vector<int>>vis(r,vector<int>(c,-1));\n        queue<pair<int,int>>qq;\n        qq.push({sx,sy});\n        vis[sx][sy] =1;\n       \n        while(qq.size()>0)\n        {\n            auto it = qq.front();\n            qq.pop();\n            int x = it.first;\n            int y=  it.second;\n            if(x==reachx && y==reachy)\n            { \n                return true;\n            }\n            for(int i=0;i<4;i++)\n            {\n                int xx = x + arr[i];\n                int yy = y+brr[i];\n                if(xx>=0 && xx<r && yy>=0 && yy<c && vis[xx][yy]==-1 && grid[xx][yy]!=\'#\'&& !(xx==bx&& yy==by))\n                {\n                    vis[xx][yy] = 1;\n                    qq.push({xx,yy});\n                }\n            }\n        }\n        return false;\n    }\n    int minPushBox(vector<vector<char>>& grid) \n    {\n       int r = grid.size();\n       int c  = grid[0].size();\n        int box_x ;\n        int box_y;\n        int t_x;\n        int t_y;\n        int s_x;\n        int s_y;\n        for(int i=0;i<r;i++)\n        {\n            for(int j=0;j<c;j++)\n            {\n                if(grid[i][j]==\'S\')\n                {\n                    s_x  = i;\n                    s_y  = j;\n                }\n                else if(grid[i][j]==\'B\')\n                {\n                    box_x = i;\n                    box_y=j;\n                }\n                else if(grid[i][j]==\'T\')\n                {\n                    t_x = i;\n                    t_y = j;\n                }\n            }\n        }\n         grid[t_x][t_y]=\'.\';\n        grid[s_x][s_y]=\'.\';\n     \n        queue<vector<int>>q;\n        q.push({box_x,box_y,s_x,s_y});\n        set<vector<int>>stt;\n        int ans =  0;\n        \n        while(q.size()>0)\n        {\n            int si = q.size();\n            while(si--)\n            {\n            auto it = q.front();\n            q.pop();\n            int x = it[0];\n            int y = it[1];\n            int ssx = it[2];\n            int ssy = it[3];\n            if(x==t_x && y==t_y)\n            {\n                return ans;\n            }\n            for(int i=0;i<4;i++)\n            {\n                int xx_new = x + arr[i];\n                int yy_new = y +brr[i];\n                int sx = x-arr[i];\n                int sy = y-brr[i];\n                if(xx_new>=0 && xx_new<r && sx>=0 && sx<r && yy_new>=0 && yy_new<c && sy>=0 && sy<c && grid[xx_new][yy_new]!=\'#\' && !stt.count({xx_new,yy_new,sx,sy}) )\n                { \n                    bool chkk = chk(grid,sx,sy,x,y,ssx,ssy);\n                    if(chkk)\n                    {\n                        stt.insert({xx_new,yy_new,sx,sy});    \n                        q.push({xx_new,yy_new,sx,sy});\n                    }\n                }\n            }\n                \n            }\n            ans++;\n            \n        }\n        \n        return -1;\n    }\n};\n```
[]