Please let me know a better approach to solve below problem: **Problem:** Vertically arrange the words in a string and print on console. <br/><br/>**Sample Input:** Hello Jack <br/>**Output:** <br/>H J <br/>e a <br/>L c <br/>L k <br/>o <br/><br/> **My solution:** public static void toVerticalWords(String str){ //split the words by whitespace String[] strArr = str.split("\\s"); int maxWordLen = 0; //get the longest word length for(String strTemp : strArr) { if(strTemp.length() > maxWordLen) maxWordLen = strTemp.length(); } //make a matrix of the words with each characetr in an array block char[][] charArr = new char[strArr.length][maxWordLen]; for(int i=0; i<strArr.length; i++) { int j=0; for(char ch : strArr[i].toCharArray()){ charArr[i][j] = ch; j++; } } //print the vertical word pattern for(int j=0; j<maxWordLen; j++) { for(int i=0; i<strArr.length; i++) { if (i!=0) System.out.print(" "); System.out.print(charArr[i][j]); } System.out.println(); } }