// Complete the encryption function below.
string encryption(string s)
{
int len= ceil(sqrt(s.size()));
string ans;
for(int i=0; i<len; i++)
{
string str;
for(int j=i;j<s.size();j+=(len))
{
str += s[j];
}
ans+= str+' ';
}
return ans;
}
Add your comment