# 2075. Decode the Slanted Ciphertext ###### tags: `Leetcode` `Medium` `String` Link: https://leetcode.com/problems/decode-the-slanted-ciphertext/description/ ## Code ```java= class Solution { public String decodeCiphertext(String encodedText, int rows) { int n = encodedText.length(); StringBuilder sb = new StringBuilder(); int cols = n/rows; for(int i=0; i<cols; i++){ for(int j=i; j<n; j+=cols+1){ sb.append(encodedText.charAt(j)); } } while(sb.length()>0 && sb.charAt(sb.length()-1)==' '){ sb.setLength(sb.length()-1); } return sb.toString(); } } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up