https://leetcode.com/problems/zigzag-conversion/
class Solution:
def convert(self, s: str, numRows: int) -> str:
answer = ""
if numRows == 1:
return s
indices = [[] for _ in range(numRows)]
unit = 2 * numRows - 2
for i in range(len(s)):
mod = i % unit
if mod < numRows:
indices[mod].append(s[i])
else:
indices[unit - mod].append(s[i])
for row in indices:
for word in row:
answer += word
return answer