Java Simple and reliable approach
Intuition \nfind no. of cols then understand the execution of loop to traverse the array to bulid the word. You can find c++ solution as well which is in commec
# Intuition \nfind no. of cols then understand the execution of loop to traverse the array to bulid the word. You can find c++ solution as well which is in commect because it is giving TLE while removing extra space at last of string so I went for Java this time.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nnested while loop while checking for cols and len value\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(n*n)\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```\nclass Solution {\n    public String decodeCiphertext(String encodedText, int rows) {\n        int len = encodedText.length();\n        if(len == 0) {\n            return "";\n        }\n        int cols = len / rows;\n        StringBuilder sb = new StringBuilder();\n        int cc = 0;\n        while(cc < cols) {\n            int temp = cc;\n            while(temp < len) {\n                sb.append(encodedText.charAt(temp));\n                temp += (cols + 1);\n            }\n            cc++;\n        }\n        String s = sb.toString().stripTrailing();\n        return s;\n    }\n}\n//rows * cols == len\n\n//c -> i\n//0 -> 5\n//0 -> (c + 1)\n        \n     /* int len = encodedText.size();\n        if(len==0)\n        return "";\n\n        string str="";\n\n        int cols = len/rows;  // 2\n        int currentColumn=0;\n\n        while(currentColumn<cols)\n        {\n            int temp = currentColumn;  // 0\n            while(temp<len)\n            {\n                str=str+encodedText[temp];\n                temp+=(cols+1);\n            }\n            currentColumn++;\n        }\n        str.erase(str.find_last_not_of(" ")+1);\n    return str;*/\n\n```
['Java']