C++ Straightforward Read and Write Pointers
See my latest update in repo LeetCode\n## Solution 1.\n\nIntuition: Treat each column separately. Use a write pointer w initialized to be N - 1. When reading a 
See my latest update in repo [LeetCode](https://github.com/lzl124631x/LeetCode)\n## Solution 1.\n\n**Intuition**: Treat each column separately. Use a write pointer `w` initialized to be `N - 1`. When reading a stone, write the stone to `w`-th row and `--w`. When reading an obstacle at row `row`, set `w = row - 1`.\n\n```cpp\n// OJ: https://leetcode.com/contest/biweekly-contest-52/problems/rotating-the-box/\n// Author: github.com/lzl124631x\n// Time: O(MN)\n// Space: O(1) extra space\nclass Solution {\npublic:\n    vector<vector<char>> rotateTheBox(vector<vector<char>>& A) {\n        int M = A.size(), N = A[0].size();\n        vector<vector<char>> ans(N, vector<char>(M, \'.\'));\n        for (int i = 0; i < M; ++i) {\n            int w = N - 1; // `w` is the write pointer\n            for (int j = N - 1; j >= 0; --j) {\n                if (A[i][j] == \'.\') continue;\n                if (A[i][j] == \'#\') {\n                    ans[w--][M - i - 1] = \'#\'; // write stone to position `(w, M - i - 1)` and move write pointer\n                } else {\n                    ans[j][M - i - 1] = \'*\';\n                    w = j - 1; // move the writer pointer to the position after the obstacle\n                }\n            }\n        }\n        return ans;\n    }\n};\n```
[]