Beats 100% ❄ || DEVIL Approach 😈 || Beginner Friendly easy 😎
\n\n# Code\ncpp []\nclass Solution {\npublic:\n    vector<vector<char>> rotateTheBox(vector<vector<char>>& box) {\n        int m=box.size(),n=box[0].size();\n  
![image.png](https://assets.leetcode.com/users/images/23edaab9-1981-4d97-b13b-5f72e1d27c91_1728444291.3986533.png)\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    vector<vector<char>> rotateTheBox(vector<vector<char>>& box) {\n        int m=box.size(),n=box[0].size();\n        vector<vector<char>>ans(n,vector<char>(m));\n        for(int i=0;i<m;i++){\n            for(int j=0;j<n;j++){\n                ans[j][i]=box[i][j];\n            }\n        }\n        for(auto &row:ans){\n            reverse(row.begin(),row.end());\n        }\n        int unique=0;\n        unordered_map<int,pair<int,pair<int,int>>>mp;\n            //uniqueKey    //Count  //i  //j\n        for(int j=0;j<m;j++){\n            int c=0;\n            for(int i=0;i<n;i++){\n                if(ans[i][j]==\'.\') continue;\n                else if(ans[i][j]==\'#\') c++;\n                else{\n                    mp[unique]={c,{i,j}};\n                    unique++;\n                    c=0;\n                }\n            }\n            if(c!=0){\n                //if no obstacle in that column\n                //assume it at nth row\n                mp[unique]={c,{n,j}};\n                unique++;\n            }\n        }\n        for(auto it:mp){\n            auto p=it.second;\n            int c=p.first,i=p.second.first,col=p.second.second;\n            for(int row=i-1;row>=0;row--){\n                if(c){\n                    ans[row][col]=\'#\';\n                    c--;\n                }\n                else{\n                    if(ans[row][col]==\'*\'){\n                        break;\n                    }\n                    ans[row][col]=\'.\';\n                }\n            }\n        }\n        return ans;\n    }\n};\n```\n\n![image.png](https://assets.leetcode.com/users/images/23edaab9-1981-4d97-b13b-5f72e1d27c91_1728444291.3986533.png)
['Array', 'Hash Table', 'Two Pointers', 'C', 'Matrix', 'Python', 'C++', 'Java', 'Python3', 'JavaScript']