You are viewing a single comment's thread. Return to all comments →
Java 8 Solution
public static String encryption(String s) { // Write your code here s = s.replaceAll(" ", ""); int sqr = (int)Math.ceil(Math.sqrt(s.length())); String[] result = new String[sqr]; for(int i = 0; i < sqr; i++){ for(int j = i; j < s.length();j = j+sqr){ char c = s.charAt(j); result[i] = j >= sqr ? result[i] + c : "" + c; } } return String.join(" ", result); }
Seems like cookies are disabled on this browser, please enable them to open this website
Encryption
You are viewing a single comment's thread. Return to all comments →
Java 8 Solution