❇ rotating-the-box👌 🏆O(N*M)❤️ Javascript🎯 Memory👀71.43%🕕 ++Explanation✍️ 🔴🔥 ✅ 👉 💪🙏
Time Complexity: O(NM)\nSpace Complexity: O(NM)\n\n\n\nvar rotateTheBox = function (box) {\n    let countStones = 0;\n    for (let rowIndex = 0; rowIndex < box.
Time Complexity: O(N*M)\nSpace Complexity: O(N*M)\n![image](https://assets.leetcode.com/users/images/98f6ef24-7d94-4b6a-a210-f1d72dbe751c_1716318024.6404052.png)\n\n```\nvar rotateTheBox = function (box) {\n    let countStones = 0;\n    for (let rowIndex = 0; rowIndex < box.length; rowIndex++) {\n        countStones = 0;\n        for (let columnIndex = 0; columnIndex < box[rowIndex].length; columnIndex++) {\n            if (box[rowIndex][columnIndex] === \'#\') {\n                box[rowIndex][columnIndex] = \'.\';\n                countStones += 1;\n            }\n            if (box[rowIndex][columnIndex] === \'*\' && countStones > 0) {\n                let tempColumnIndex = columnIndex - 1;\n                while (countStones > 0) {\n                    box[rowIndex][tempColumnIndex--] = \'#\';\n                    countStones--;\n                }\n                countStones = 0;\n            }\n            if (columnIndex === box[rowIndex].length - 1 && countStones > 0) {\n                let tempColumnIndex = columnIndex;\n                while (countStones > 0) {\n                    box[rowIndex][tempColumnIndex--] = \'#\';\n                    countStones--;\n                }\n                countStones = 0;\n            }\n        }\n    }\n    const output = [];\n    for (let columnIndex = 0; columnIndex < box[0].length; columnIndex++) {\n        output[columnIndex] = [];\n        for (let rowIndex = box.length - 1; rowIndex >= 0; rowIndex--) {\n            output[columnIndex].push(box[rowIndex][columnIndex]);\n        }\n    }\n    return output;\n};\n```
['JavaScript']