standard  BFS Approach solution ,clean Code ,BFS*BFS
Intuition\nwe use BFS to find minimum distance \n\n# Approach\nBFS * BFS\n# Complexity\n- Time complexity:\nO(n^2 * m^2) \n\n- Space complexity:\n O(n^2 * m^2) 
# Intuition\nwe use BFS to find minimum distance \n\n# Approach\nBFS * BFS\n# Complexity\n- Time complexity:\n$$O(n^2 * m^2)$$ \n\n- Space complexity:\n $$O(n^2 * m^2)$$ \n\n# Code\n```\nclass Solution {\npublic:\nint dx[4]={0,0,1,-1};\nint dy[4]={1,-1,0,0};\nint m,n;\n\nbool check(int x,int y,vector<vector<char>>& grid ){\nreturn (x>=0 && x<m ) && (y>=0 && y<n) && (grid[x][y]!=\'#\');\n}\n\n\nbool possible(int px,int py,int npx,int npy,int bx,int by,vector<vector<char>>& grid){\n    queue<vector<int>>q;\n     vector<vector<bool>>vis(m,vector<bool>(n,false));\n     vis[px][py]=true;\n    q.push({px,py});\n    while(!q.empty()){\n        auto it=q.front();\n        q.pop();\n        if(it[0]==npx && it[1]==npy){\n            return true;\n        }\n        for(int i=0;i<4;i++){\n            int x=it[0]+dx[i],y=it[1]+dy[i];\n            if(check(x,y,grid) && !(x==bx && y==by) && vis[x][y]==false){\n                vis[x][y]=true;\n                q.push({x,y});\n            }\n        }\n        \n    }\n    return false;\n\n}\n    int minPushBox(vector<vector<char>>& grid) {\n        m=grid.size(),n=grid[0].size();\n        int bx,by,tx,ty,px,py;\n        for(int i=0;i<m;i++){\n            for(int j=0;j<n;j++){\n                if(grid[i][j]==\'T\'){\n                    tx=i;\n                    ty=j;\n                }\n                 if(grid[i][j]==\'B\'){\n                    bx=i ;\n                    by=j;\n                } \n                if(grid[i][j]==\'S\'){\n                    px=i;\n                    py=j;\n                }\n            }\n        }\n\n       \n    int seen[20][20][20][20]={0};\n        queue<vector<int>>q;\n        q.push({bx,by,px,py});\n         seen[bx][by][px][py];\n        int ans=0;\n        while(!q.empty()){\n            int sz=q.size();\n            while(sz--){\n                auto vec=q.front();\n                q.pop();\n                bx=vec[0],by=vec[1],px=vec[2],py=vec[3];\n                if(bx==tx && by==ty)\n                return ans;\n                for(int i=0;i<4;i++){\n                    int nbx=bx+dx[i],nby=by+dy[i],npx=bx-dx[i],npy=by-dy[i];\n                    if(check(nbx,nby,grid) && possible(px,py,npx,npy,bx,by,grid) && seen[nbx][nby][bx][by]==0){\n                                seen[nbx][nby][bx][by]=1;\n                                q.push({nbx,nby,bx,by});\n                    }  \n                }\n            }\n            ans++;\n\n        }\n    return -1;   \n    } \n    \n};\n```
['C++']