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.
classResult{/* * Complete the 'encryption' function below. * * The function is expected to return a STRING. * The function accepts STRING s as parameter. */publicstaticstringencryption(strings){s=s.Replace(" ","");intsz=s.Length;doubleqrt=Math.Sqrt(sz);intslc=(int)Math.Ceiling(qrt);intslf=(int)Math.Floor(qrt);char[,]ans=newchar[slc,slc];intlstjidx=0;for(inti=0;i<slc;i++){for(intj=0;j<slc&&lstjidx<sz;j++,lstjidx++){ans[i,j]=s[lstjidx];}}stringans2="";for(inti=0;i<slc;i++){for(intj=0;j<slc;j++){ans2+=ans[j,i];}if(i<slc-1)ans2+=" ";}returnans2;}}
in C# : sample cases shows WA while all expected and my output are exact same (not extra white character or new line characters?
textWriter.Flush();
textWriter.Close();
}
}
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 →
in C# : sample cases shows WA while all expected and my output are exact same (not extra white character or new line characters?
}