• + 0 comments

    Java

    public static String encryption(String s) {
        // Write your code here
        
        double squareRoot = Math.sqrt(s.length());
        int column = (int)Math.ceil(squareRoot);
        
        String output="";
        for (int i = 0; i < column; i++) {
            for (int j = i; j < s.length(); j+=column) {
                output+=s.charAt(j);
            }
            output+=" ";
        }
            return output;
        }