Decode the Slanted Ciphertext LeetCode solution in Python

1
class Solution:
2
def decodeCiphertext(self, encodedText: str, rows: int) -> str:
3
n = len(encodedText)
4
cols = n // rows
5
step = cols + 1
6
res = ""
7

8
for i in range(cols):
9
for j in range(i, n, step):
10
res += encodedText[j]
11

12
return res.rstrip()

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0