Leetcode python 06:Valid Parentheses

陈沙克日志 at 
这道题是判断输入的符号是否合法。 https://leetcode.com/problems/valid-parentheses/ 这道题涉及到所谓栈,stack,所谓的后进先出。这个需要理解一下。 class Solution: def isValid(self, s: str) -> bool: stack = [] dic={'(':')','[':']','{':'}'} for i in s: if i in dic: stack.append(i) elif len (stack)== 0 or dic[stack.pop()]!=i: return False return le……