9 line C++ beating 100/99% Solution
Code\ncpp []\nclass Solution {\npublic:\n    vector<vector<char>> rotateTheBox(vector<vector<char>>& box) {\n        ios_base::sync_with_stdio(0), cin.tie(0), c
# Code\n```cpp []\nclass Solution {\npublic:\n    vector<vector<char>> rotateTheBox(vector<vector<char>>& box) {\n        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);\n        int n = size(box), m = size(box[0]), k = n - 1, p;\n        vector<vector<char>> v(m, vector<char>(n, \'*\'));\n        for (int i = 0; i < n; i++, k--) {\n            for (int j = p = 0; j < m; j++) {\n                if (box[k][j] == \'.\') v[j][i] = v[p][i], v[p++][i] = \'.\'; else if (box[k][j] == \'#\') v[j][i] = \'#\'; else p = j + 1;\n            }\n        }\n        return v;\n    }\n};\n```\n# Intuition\nThe `\'*\'` characters should remain constant. For each column, all of the groups separated by `\'*\'` characters/without `\'*\'` characters should have all of the `\'#\'` characters to the right and all of the `\'.\'` characters to the left.\n\n# Approach\nUse an index to keep track of the previous `\'#\'` character and when a `\'.\'` character is found, swap it with that character and increment it. If there is a `\'*\'` character, update that to the most recent index.\n\n# Complexity\n- Time & Space complexity:\n$$O($$`n`$$ * $$`m`$$)$$\n\n
['C++']