C++ | Easy Solution | Simulation | Diagonal traversal
Intuition\nColumns = encodedText.size/rows . Now make the grid as given in example and do diagonal traversal from every column.\n\n\n# Code\n\nclass Solution {\
# Intuition\n**Columns = encodedText.size/rows** . Now make the grid as given in example and do diagonal traversal from every column.\n\n\n# Code\n```\nclass Solution {\npublic:\n    string decodeCiphertext(string eT, int rows) {\n        int n = eT.size();\n        if(n==0)\n        return "";\n        int cols = n/rows;\n        vector<vector<char>> grid(rows,vector<char>(cols));\n        int ptr = 0;\n        int col = 0;\n        int row = 0;\n        while(ptr<n)\n        {\n            grid[row][col] = eT[ptr];\n            ptr++;\n            col = (col+1)%cols;\n            if(col==0)\n            row++;\n        }\n        string ans = "";\n        for(int j=0;j<cols;j++)\n        {\n            int c = j;\n            int r = 0;\n            while(c<cols && r<rows)\n            {\n                ans+=grid[r][c];\n                c++;\n                r++;\n            }\n        }\n        while(ans[ans.size()-1]==\' \')\n        ans.pop_back();\n        return ans;\n    }\n};\n```
['Simulation', 'C++']