In C++
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    string decodeCiphertext(string encodedText, int rows) {\n        if (rows == 1) return encodedText;\n\n        int cols = encodedText.size() / rows;\n        string result;\n\n        // Traverse the matrix diagonally\n        for (int startCol = 0; startCol < cols; ++startCol) {\n            int r = 0, c = startCol;\n            while (r < rows && c < cols) {\n                result.push_back(encodedText[r * cols + c]);\n                ++r;\n                ++c;\n            }\n        }\n\n        // Remove trailing spaces\n        while (!result.empty() && result.back() == \' \') {\n            result.pop_back();\n        }\n\n        return result;\n    }\n};\n```
['C++']