Simplest Approach
\n\n\n\n# Approach\nmove to the first empty space to the right\n\n# Complexity\n- Time complexity:\n\n    O(mn) traversing each element once.\n   \n- Space comp
\n\n\n\n# Approach\nmove to the first empty space to the right\n\n# Complexity\n- Time complexity:\n\n    O(m*n) traversing each element once.\n   \n- Space complexity:\n   O(n*m) for the output.\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    vector<vector<char>> rotateTheBox(vector<vector<char>>& box) {\n        vector<vector<char>> ans(box[0].size(), vector<char>(box.size(), \'.\'));\n        int m = box.size();\n        int n = box[0].size();\n        for(int i=0 ; i<m; i++){\n            int lastFillerIndex= box[0].size()-1;\n            for(int j=n-1; j>=0; j--){\n                \n                if(box[i][j]==\'*\'){\n                    lastFillerIndex = j-1;\n                    ans[j][m-i-1] = \'*\';\n\n                }\n                \n                else if(box[i][j]==\'#\'){\n                    if(j<lastFillerIndex){\n                        ans[lastFillerIndex][m-i-1] = \'#\';\n                        ans[j][m-i-1]=\'.\';\n                        lastFillerIndex--;\n                    }\n                    else{\n                        ans[j][m-i-1] = \'#\';\n                        lastFillerIndex = j-1;\n                    }\n                }\n\n            }\n        }\n        return ans;\n        \n    }\n};\n```
['C++']