有效的括号 实现思路 设立判定条件遍历的范围 代码实现 class Solution(object): def isValid(self, s): """ :type s: str :rtype: bool """ n=len(s) for i in range(0,n-1): if s[i]=='(' and s[i+1]!=')': return False if s[i]=='[' and s[i+1]!=']': return False if s[i]=='{' and s[i+1]!='}': return False return True