C++ | Diagonal Traversal | O(N) Time & Space
\nclass Solution {\npublic:\n    string decodeCiphertext(string encodedText, int rows) {\n        string res = "";\n        int n = encodedText.size();\n       
```\nclass Solution {\npublic:\n    string decodeCiphertext(string encodedText, int rows) {\n        string res = "";\n        int n = encodedText.size();\n        int cols = n / rows;\n        vector<vector<char>> v(rows, vector<char>(cols));\n        for(int i=0; i<rows; i++){\n            for(int j=0; j<cols; j++){\n                v[i][j] = encodedText[i*cols + j];\n            }\n        }\n        for(int g=0; g<cols; g++){\n            for(int i=0, j=i+g; i<rows && j<cols; i++, j++){\n                res += v[i][j];\n            }\n        }\n        int l = res.length();\n        while(l > 0 && res[l-1] == \' \'){\n            res.pop_back();\n            l--;\n        }\n        return res;\n    }\n};\n```
['C', 'C++']