[Java] Interview Easy to Come Up
So idea here is\n1. First turn 90 degree\n2. Make things fall\n\n\n// O(n^2) time | O(n^2) space\nclass Solution {\n    public char[][] rotateTheBox(char[][] bo
**So idea here is**\n1. First turn 90 degree\n2. Make things fall\n\n```\n// O(n^2) time | O(n^2) space\nclass Solution {\n    public char[][] rotateTheBox(char[][] box) {\n        int m = box.length;\n        int n = box[0].length;\n        char[][] matrix = new char[n][m];   \n        \n        turnBox(box, matrix, m, n); // turn the box clockwise 90 degree\n        \n        turnGravity(matrix, n, m); // cause that falling effect, since matrix turned so n,m\n        \n        return matrix;\n    }\n    \n    public void turnGravity(char[][] matrix, int m, int n){\n        for(int c = 0; c < n; c++){\n            int last  = m-1;\n            for(int r = m-1; r >= 0; r--){\n                char val =  matrix[r][c];\n                if(val == \'.\') continue;\n                if(val == \'*\') last = r-1;\n                if(val == \'#\') {\n                    matrix[r][c] = \'.\';\n                    matrix[last][c] = \'#\';\n                    last--;\n                }\n            }\n        }\n    }\n    \n    public void turnBox(char[][] box, char[][] matrix, int m, int n){\n\t// numbers represents sequence it would be copied\n\t//[4][1]\n\t//[5][2]\n\t//[6][3]\n        for(int i = 0, c = m-1; i < m; i++,c--){ // c: 4,3,2,1..\n            for(int j = 0, r = 0; j < n; j++, r++){ // r:0,1,2,3..\n               matrix[r][c] = box[i][j];\n            }\n        }\n    }\n}\n```
['Java']