Commit d31a52d2 by 牛家玺

Z变换

parent e2a30cf9
def convert(s, numRows):
"""
:type s: str
:type numRows: int
:rtype: str
"""
\ No newline at end of file
# 初始化数组
rows = [''] * numRows
index = 0
isInc = True
for char in s:
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