Java solution
\nclass Solution {\n    public char[][] rotateTheBox(char[][] box) {\n      \t\n\t\tint n = box.length;\n\t\tint m = box[0].length;\n\t\tchar[][] ans = new char
```\nclass Solution {\n    public char[][] rotateTheBox(char[][] box) {\n      \t\n\t\tint n = box.length;\n\t\tint m = box[0].length;\n\t\tchar[][] ans = new char[m][n];\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tint count = 0;\n\t\t\tint j = 0;\n\t\t\tint prev = -1;\n\t\t\twhile (j < m) {\n\t\t\t\tif (box[i][j] == \'#\')\n\t\t\t\t\tcount++;\n\t\t\t\telse if (box[i][j] == \'*\') {\n\t\t\t\t\tfill(ans, i, count, j, prev, n, true);\n\t\t\t\t\tcount = 0;\n\t\t\t\t\tprev = j;\n\t\t\t\t}\n\t\t\t\tj++;\n\t\t\t}\n\t\t\tfill(ans, i, count, j, prev, n, false);\n       }\n\t\treturn ans;\n\t}\n\n\tprivate static void fill(char[][] ans, int col, int count, int pos, int prev, int n, boolean obs) {\n\t\tif (obs )\n\t\t\tans[pos][n - col - 1] = \'*\';\n\n\t\tpos--;\n\t\twhile (pos > prev) {\n\t\t\tif (count > 0) {\n\t\t\t\tans[pos][n - col - 1] = \'#\';\n\t\t\t\tcount--;\n\t\t\t} else {\n\t\t\t\tans[pos][n - col - 1] = \'.\';\n\t\t\t}\n\t\t\tpos--;\n\t\t}\n\n\t}\n}\n```
['Java']