#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
# 
# @param s string字符串 
# @param numRows int整型 
# @return string字符串
#
class Solution:
    def decodeFlag(self , s: str, numRows: int) -> str:
        # write code here
        # 用numRows个字符串来存,放到一个list里
        # 用 numRows做往复指针,遍历字符串
        lines = []
        for i in range(numRows):
            lines.append('')
        row = 0
        # 用来标记当前是在往下还是往上,0向下,1向上
        direction = 0

        for j in range(len(s)):
            lines[row] += s[j]
            
            if row == 0:
                direction = 0
            elif row == numRows - 1:
                direction = 1
            
            if direction == 0:
                row += 1
            else:
                row -= 1
        
        return ''.join(lines)