C++ straightforward solution.
\n\nGet col number with encodedText.size() / rows and then re-construct the answer with the rules.\n\n\nclass Solution {\npublic:\n    string decodeCiphertext(s
\n\nGet col number with `encodedText.size() / rows` and then re-construct the answer with the rules.\n\n```\nclass Solution {\npublic:\n    string decodeCiphertext(string encodedText, int rows) {\n        int cols = encodedText.size() / rows;\n        string ans;\n        for(int i = 0; i < cols; i++) {\n            for(int j = 0; j < rows; j++) {\n                int idx = j * cols + j + i;\n                if(idx >= encodedText.size()) break;\n                ans += encodedText[idx];\n            }\n        }\n        while(ans.back() == \' \' && ans.size())ans.pop_back();\n        return ans;\n    }\n};\n```\n
[]