Skip to content

Commit fa274e1

Browse files
committed
add problem
1 parent 72f7f09 commit fa274e1

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

Easy/valid_parentheses.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ def isValid(self, s):
44
:type s: str
55
:rtype: bool
66
"""
7+
8+
if len(s)%2 != 0 or len(s) > 10000:
9+
return False
10+
711
mapParentheses = {"(": ")","[": "]", "{": "}"}
812
collectParentheses = []
913

Medium/zigzag_conversion.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
class Solution(object):
2+
def convert(self, s, numRows):
3+
"""
4+
:type s: str
5+
:type numRows: int
6+
:rtype: str
7+
"""
8+
mapLetter = [[] for _ in range(numRows)]
9+
# strReverse = list(s)[::-1]
10+
# print(strReverse)
11+
start = 0
12+
iLetter = 0
13+
14+
for i, _ in enumerate(mapLetter):
15+
if iLetter > len(s):
16+
break
17+
18+
if start == 0:
19+
mapLetter[i].append(s[iLetter])
20+
21+
iLetter += 1
22+
23+
if start < numRows:
24+
start = 0
25+
else:
26+
start += 1
27+
28+
print(mapLetter)
29+
30+
31+
print(Solution().convert("PAYPALISHIRING", 3))
32+

0 commit comments

Comments
 (0)