Easy C++ solution - Beats 96% time
Intuition\nFirst calculate number of columns by dividing total length of string by total rows. \nThe next letter of the sequence will always be given by \n\nx+k
# Intuition\nFirst calculate number of columns by dividing total length of string by total rows. \nThe next letter of the sequence will always be given by \n\n**x+k*no_cols+k**\n\n\nHere k is incremented after each step and is initialized to zero once we have reached the bottom row (since after each downward iteration we have to start from the top again). \nx helps shift the next downward iteration towards the right.\n\nWe continue appending letters to our result string until an out of bound index is reached. Then we remove all white spaces from the end of our result string. This gives us our final output string.\n\n# Code\n```\nclass Solution {\npublic:\n    string decodeCiphertext(string encodedText, int rows) {\n        if(rows==1){return encodedText;}\n\n        string result="";\n        int x=0;\n        int no_cols=encodedText.length()/rows,k=0;\n        for(int i=0;i<encodedText.length();i++){\n\n            //End loop when index starts going out of range then remove white spaces from end\n            if(x+k*no_cols+k>=encodedText.length()){\n                for(int j=result.length()-1;j>=0;j--){  \n                    if(result[j]!=\' \'){\n                        if(j<=result.length()-1){\n                        result.erase(j+1);}  //Remove white spaces from end\n                        break;}\n                }\n                break;\n            }\n\n            result.push_back(encodedText[x+k*no_cols+k]); //Push text to the end\n            \n            if((k+1)%rows==0){x++;k=-1;}\n            k++;\n        }\n        return result;\n\n    }\n};\n```
['Math', 'String', 'C++']