Commit d31a52d2 by 牛家玺

Z变换

parent e2a30cf9
def convert(s, numRows): def convert(s, numRows):
""" # 初始化数组
:type s: str rows = [''] * numRows
:type numRows: int index = 0
:rtype: str isInc = True
""" for char in s:
\ No newline at end of file if index == 0:
isInc = True
elif index + 1 == numRows:
isInc = False
offset = 1 if isInc else - 1
rows[index] = rows[index] + char
index = index + offset
str = ''
for row in rows:
str = str + row
print(str)
str = "0123456789"
str = "LEETCODEISHIRING"
convert(str, 3)
convert(str, 4)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment