1614. Maximum Nesting Depth of the Parentheses

Обновлено: 2024-04-15
1 мин
[]

Содержание

LeetCode problem 1614

class Solution:
    def maxDepth(self, s: str) -> int:
        stack = []
        res = 0
        for c in s:
            if c == '(':
                stack.append(1)
                res = max(res, len(stack))
            elif c == ')':
                stack.pop()
        
        return res