[简单遍历] leetcode1614. 括号的最大嵌套深度

leetcode1614. 括号的最大嵌套深度

def maxDepth(self, s: str) -> int:
    cur = res = 0
    for i in s:
        if i == "(":
            cur += 1
            res = max(cur, res)
        if i == ")":
            cur -= 1
    return res

你可能感兴趣的:(leetcode,leetcode)