Beginner friendly brute force approach in Java
Intuition\nIt is a simple beginner friendly brute force approach.\nConstruct a matrix with given encoded text.\n# Approach\nFirst find the number of columns by 
# Intuition\nIt is a simple beginner friendly brute force approach.\nConstruct a matrix with given encoded text.\n# Approach\nFirst find the number of columns by dividing the length of the string by number of rows\nNext store the string characters in a matrix.\nObserve the pattern in order to get the decoded text we have to traverse in the following pattern\n00 11 22 33 ......\n01 12 23 34 ......\n02 13 24 35 ......\n..................\nSo write two for loops to generate the above pattern in the order 00,11,22,....row row, 01,12,23,34,.... row row+1 and so on.\n# Complexity\n- Time complexity:\nO(m\\*n) + O(m\\*n)\none for matrix construction and another for traversal\nm,n are no of rows and columns of the matrix\n\n- Space complexity:\nO(m\\*n)\nsince we are using an extra space to store the matrix\n\n# Code\n```\nclass Solution {\n    public String decodeCiphertext(String encodedText, int rows) {\n        int cols = encodedText.length() / rows;\n        char[][] matrix = new char[rows][cols];\n        int stringIndex = 0;\n        for(int i = 0; i < rows; i++) {\n            for(int j = 0; j < cols; j++) {\n                matrix[i][j] = encodedText.charAt(stringIndex++);\n            }\n        }\n        //String res = "";\n        StringBuilder res = new StringBuilder();\n\n        for (int i = 0; i < cols; i++) {\n            int start = 0;\n            for (int j = 0; j < rows; j++) {\n                int rowIndex = start;\n                int colIndex = start + i;\n                if (rowIndex < rows && colIndex < cols) {\n                    res.append(matrix[rowIndex][colIndex]);\n                }\n                start++;\n            }\n        }\n        return res.toString().replaceAll("\\\\s+$", "");\n    }\n}\n```
['Iterator', 'Java']