Skip to content

Commit 8921ee0

Browse files
committed
committed from zkp
1 parent e3ff48f commit 8921ee0

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

LeetCode/Z_convert.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
class Solution:
2+
def convert(self, s, numRows):
3+
"""
4+
:type s: str
5+
:type numRows: int
6+
:rtype: str
7+
"""
8+
if numRows == 1:
9+
return s
10+
t = [[] for i in range(numRows)]
11+
j = 0
12+
st = 0
13+
for i in s:
14+
t[j].append(i)
15+
if st == 0:
16+
j+=1
17+
else:
18+
j -= 1
19+
if j in (numRows-1,0):
20+
if st == 0:
21+
st =1
22+
else:
23+
st =0
24+
s = ''
25+
for i in t:
26+
for j in i:
27+
s += j
28+
return s

0 commit comments

Comments
 (0)