Beginner Friendlly,  Logic explained
Intuition\n Describe your first thoughts on how to solve this problem. \nHow you think forthis problem? yeah i am asking in brute force approach! Ok read my ste
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nHow you think forthis problem? yeah i am asking in brute force approach! Ok read my steps\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nput the encodedText as diagonally, how ? you are given with rows you only need to find no. of cols to fit encodedText\n\nok now see the written next steps, and dont foreget to do dry run if you really want to get this solution else this will be a waste of time.\n![2075.jpeg](https://assets.leetcode.com/users/images/cde02ff5-741f-4fc5-9b56-8d88f3782594_1711384740.6254396.jpeg)\n\n\n# Complexity\n- Time complexity:O(rows*col)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(rows*col)\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        if(encodedText.length()<=1) return encodedText;\n        int col=encodedText.length()/rows;\n        char[][] mat=new char[rows][col];\n        int eIndex=0;\n        for(int i=0;i<rows;i++){\n\n            for(int j=0;j<col;j++){\n                mat[i][j]=encodedText.charAt(eIndex++);\n\n            }\n        }\n        // display(mat);\n        // String res="";\n        StringBuilder res = new StringBuilder();\n\n        for(int j=0;j<col;j++){\n            int t=j;\n\n            for(int i=0;i<rows;i++){\n                if(i==rows || t==col) break;\n                res.append(mat[i][t++]);\n            }\n        }\n        // int x =0;\n        // for(int k=res.length()-1;k>=0;k--){\n        //     if(res.charAt(k)> 96 && res.charAt(k)<123) {\n        //         x=k;\n        //         break;\n        //     }\n\n        // }\n\n          return res.toString().replaceAll("\\\\s+$", "");\n    }\n    public void display(char[][] arr){\n        \n        for(int i=0;i<arr.length;i++){\n\n            for(int j=0;j<arr[0].length;j++){\n                System.out.print(arr[i][j]+" ");\n            }\n            System.out.println();\n\n        }\n    }\n}\n```
['Java']