We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
public static String encryption(String s) {
// Write your code here
s=s.replaceAll("\s","");
int len = s.length();
double L = Math.sqrt(len);
int r = (int)Math.floor(L);
int c = (int)Math.ceil(L);
int n;
n = r*c;
if(nlen){
en[i] = s.substring(j,len);
}
else{
en[i] = s.substring(j,j+c);
j = j+c;
}
}
String out="";
for(int i=0;ien[j].length()-1)
continue;
else
out += en[j].charAt(i);
![]([](https://)https://)
}
out += " ";
}
return out;
**}
Cookie support is required to access HackerRank
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 →
public static String encryption(String s) { // Write your code here s=s.replaceAll("\s",""); int len = s.length(); double L = Math.sqrt(len); int r = (int)Math.floor(L); int c = (int)Math.ceil(L); int n; n = r*c; if(nlen){ en[i] = s.substring(j,len); } else{ en[i] = s.substring(j,j+c); j = j+c; } } String out=""; for(int i=0;ien[j].length()-1) continue; else out += en[j].charAt(i);