C++ Simulation
See my latest update in repo LeetCode\n## Solution 1. Simulation\n\nSimply traverse the string diagonally. Position (x, y) corresponds to s[y * col + x].\n\ncpp
See my latest update in repo [LeetCode](https://github.com/lzl124631x/LeetCode)\n## Solution 1. Simulation\n\nSimply traverse the string diagonally. Position `(x, y)` corresponds to `s[y * col + x]`.\n\n```cpp\n// OJ: https://leetcode.com/problems/decode-the-slanted-ciphertext/\n// Author: github.com/lzl124631x\n// Time: O(N)\n// Space: O(N)\nclass Solution {\npublic:\n    string decodeCiphertext(string s, int row) {\n        int col = s.size() / row;\n        string ans;\n        for (int i = 0; i < col; ++i) { // start from each column\n            for (int x = i, y = 0; x < col && y < row; ++x, ++y) ans += s[y * col + x]; // traverse the string diagonally\n        }\n        while (ans.size() && ans.back() == \' \') ans.pop_back();\n        return ans;\n    }\n};\n```
[]