Two simple JAVA solutions
Option 1:\nFirst we rotate the original matrix, then drop the stones.\n\n\n\n class Solution {\n     public char[][] rotateTheBox(char[][] box) {\n         int 
**Option 1:**\nFirst we rotate the original matrix, then drop the stones.\n![image](https://assets.leetcode.com/users/images/0e1bad47-9fd3-43b6-9f52-bc900ae9d2b2_1628288206.3706853.png)\n\n```\n class Solution {\n     public char[][] rotateTheBox(char[][] box) {\n         int row = box.length, col = box[0].length;\n         char[][] res = new char[col][row];\n         // rotate first, then drop\n         for (int i = 0; i < row; i++) {\n             for (int j = 0; j < col; j++) {\n                 res[j][i] = box[row-1-i][j];\n             }\n         }\n        \n\t\tfor (int i = col - 1; i >= 0; i--) {\n             for (int j = 0; j < row; j++) {\n                 if (res[i][j] == \'#\') {\n                     int curRow = i;\n                     while (curRow+1 < col && res[curRow+1][j] == \'.\') {\n                         curRow++;\n                     }\n                     if (curRow != i) {\n                         res[curRow][j] = \'#\';\n                         res[i][j] = \'.\';\n                     }\n                 }\n             }\n         }\n         return res;\n     }\n }\n```\n\n\n<br>\n\n**Option 2:**\nFirst we move the stones to its furthest right (if there are empty spaces on the right), then rotate the altered matrix.\n![image](https://assets.leetcode.com/users/images/5095bfc4-33f4-48b0-9135-93c8f1781d7f_1628288262.448106.png)\n\n```\nclass Solution {\n    public char[][] rotateTheBox(char[][] box) {\n        int row = box.length, col = box[0].length;\n        char[][] res = new char[col][row];\n        // move right then rotate\n        for (int i = 0; i < row; i++) {\n            for (int j = col-1; j >= 0; j--) {\n                if (box[i][j] == \'#\') {\n                    int curCol = j;\n                    while (curCol+1 < col && box[i][curCol+1] == \'.\') {\n                        curCol++;\n                    }\n                    if (curCol != j) {\n                        box[i][curCol] = \'#\';\n                        box[i][j] = \'.\';\n                    }\n                }\n            }\n        }\n        \n        for (int i = 0; i < row; i++) {\n            for (int j = 0; j < col; j++) {\n                res[j][i] = box[row-1-i][j];\n            }\n        }\n        return res;\n    }\n}\n```
['Java']