[Java] There is plenty of room at the bottom
Stone falls until you encounter an obstacle or just another stone, using this idea we iterate the given matrix in a row wise manner from the rear end(going to b
Stone falls until you encounter an obstacle or just another stone, using this idea we iterate the given matrix in a row wise manner from the rear end(going to be bottom) and until the front end(going to be top), if we have an empty slot adjacent to the stone we move it until there is no room on the right, the elapsed position become empty after each momvement.\n\nThe matrix after the in place modification just needs to be rotated 90 degree clockwise and the box is now tilted!\n```\n\tpublic char[][] rotateTheBox(char[][] box) {\n        for(char[] row : box) {\n            for(int i=row.length-1;i>=0;i--) {\n                int j = i + 1;\n                if(row[i] == \'#\') {\n                    while(j < row.length && row[j] == \'.\') {\n                        row[j] = \'#\';\n                        if(j > 0)\n                            row[j - 1] = \'.\';\n                        j++;\n                    }\n                }\n            }\n        }\n        char[][] res = new char[box[0].length][box.length];\n        for(int i=0;i<box.length;i++) {\n            for(int j=0;j<box[0].length;j++) {\n                res[j][i] = box[box.length - i - 1][j];\n            }\n        }\n        return res;\n    }\n```\t\n\nComplexity Analysis\n```\n\tTime: O(m * n)\n\tSpace: O(m * n)\n```
['Java']