C++ 2d index conversion
\nclass Solution {\npublic:\n    string decodeCiphertext(string s, int r) {\n        int c = s.size() / r;\n        string ans = "";\n        for (int i = 0; i 
```\nclass Solution {\npublic:\n    string decodeCiphertext(string s, int r) {\n        int c = s.size() / r;\n        string ans = "";\n        for (int i = 0; i < c; ++i)\n            ans += findDiagonal(0, i, s, c, r);\n        while (!ans.empty() && ans.back() == \' \') ans.pop_back();\n        return ans;\n    }\n    string findDiagonal(int i, int y, string& s, int& c, int& r){\n        int nextInd = i * c + y;\n        if (nextInd >= s.size()) return "";\n        return s[nextInd] + findDiagonal(i + 1, y + 1, s, c, r);\n    }\n};\n```
[]