We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents b0d162a + 54db6fc commit a379699Copy full SHA for a379699
solution/020.Valid Parentheses/Solution.py
@@ -21,4 +21,26 @@ def isValid(self, s):
21
pass
22
else:
23
f=False
24
- return f
+ return f
25
+
26
+class Solution():
27
+ def isValid(self,s):
28
+ """
29
+ :type s: str
30
+ :rtype: bool
31
32
+ left=['(','{','[']
33
+ right={ ')':'(',
34
+ ']':'[',
35
+ '}':'{' }
36
+ stack=[]
37
+ for i in s:
38
+ if i in left:
39
+ stack.append(i)
40
+ elif stack and right[i] == stack.pop():
41
+ continue
42
+ else:
43
+ return False
44
+ if stack:
45
46
+ return True
solution/344.Reverse String/Solution.py
@@ -0,0 +1,15 @@
1
+class Solution:
2
+ def reverseString(self, s):
3
4
5
+ :rtype: str
6
7
+ length=len(s)
8
+ if length < 2:
9
+ return s
10
+ ns=''
11
+ p=length-1
12
+ while p >= 0:
13
+ ns += s[p]
14
+ p-=1
15
+ return ns
0 commit comments