We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e3ff48f commit 8921ee0Copy full SHA for 8921ee0
1 file changed
LeetCode/Z_convert.py
@@ -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
21
+ st =1
22
23
+ st =0
24
+ s = ''
25
+ for i in t:
26
+ for j in i:
27
+ s += j
28
0 commit comments