File tree Expand file tree Collapse file tree 1 file changed +22
-22
lines changed Expand file tree Collapse file tree 1 file changed +22
-22
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ Output: true
7070> 入: push 出 shift 就是队列
7171## 代码
7272
73-
73+ Javascript Code:
7474``` js
7575/*
7676 * @lc app=leetcode id=20 lang=javascript
@@ -163,29 +163,29 @@ var isValid = function(s) {
163163 return valid;
164164};
165165```
166- Python Code
166+ Python Code:
167167```
168- class Solution:
169- def isValid(self,s):
170- stack = []
171- map = {
172- "{":"}",
173- "[":"]",
174- "(":")"
175- }
176- for x in s:
177- if x in map:
178- stack.append(map[x])
179- else:
180- if len(stack)!=0:
181- top_element = stack.pop()
182- if x != top_element:
183- return False
168+ class Solution:
169+ def isValid(self,s):
170+ stack = []
171+ map = {
172+ "{":"}",
173+ "[":"]",
174+ "(":")"
175+ }
176+ for x in s:
177+ if x in map:
178+ stack.append(map[x])
184179 else:
185- continue
186- else:
187- return False
188- return len(stack)==0
180+ if len(stack)!=0:
181+ top_element = stack.pop()
182+ if x != top_element:
183+ return False
184+ else:
185+ continue
186+ else:
187+ return False
188+ return len(stack)==0
189189```
190190
191191## 扩展
You can’t perform that action at this time.
0 commit comments