Simple O(MN) Iterative Approach with 50% Runtime
\nclass Solution {\n    char[][] ans, box;\n    int maxRow, maxCol;\n    public char[][] rotateTheBox(char[][] box) {\n        this.box = box;\n        int row,
```\nclass Solution {\n    char[][] ans, box;\n    int maxRow, maxCol;\n    public char[][] rotateTheBox(char[][] box) {\n        this.box = box;\n        int row, col, start, end;\n        maxRow = box.length;\n        maxCol = box[0].length;\n        ans = new char[maxCol][maxRow];\n        row = 0;\n\t\t//Traversing the matrix\n        for(row = 0; row < maxRow; row++) {\n            col = 0;\n            while(col < maxCol) {\n\t\t\t\t// If a stone is not encountered then we look for a window starting(inclusive) from that index till the next stone or end of array ie end(exclusive).\n                if(box[row][col] != \'*\') {\n                    start = col;\n                    col = findWindow(row, start);\n                } else // If a stone is encountered then we put * in the corresponding indices in the answer matrix.\n                    ans[col][maxRow-row-1] = \'*\';\n                col++;\n            }\n        }\n        return ans;\n    }\n\t// This function finds the window from start till * or end of array in the row\'th row of matrix.\n    public int findWindow(int row, int start) {\n        int rock = 0, air = 0, end = start;\n        while(end < maxCol && box[row][end] != \'*\') \n            if(box[row][end++] == \'.\')\n                air++;\n            else \n                rock++;\n        putValues(row, start, end, rock, air);\n        return end;\n    } \n\t// We use the give window to put the stars and rocks in this window. We place air first and then stones as air is always above the stone. (I mean Gravity guys!!)\n    public void putValues(int row, int start, int end, int rock, int air) {\n        while(start < end) {\n            if(air-- > 0) {\n                ans[start++][maxRow-row-1] = \'.\';\n            } else {\n                ans[start++][maxRow-row-1] = \'#\';\n                rock--;\n            }\n        }\n        if(start < maxCol)\n            ans[start][maxRow-row-1] = \'*\';\n    }\n}\n```
[]