- 最大括号嵌套深度
在给定字符串中,找到最大的括号嵌套深度。
以下是一种 Python 实现的方法:
class Solution:
def maxDepth(self, s: str) -> int:
stack = []
max_depth = 0
for c in s:
if c == '(':
stack.append(c)
max_depth = max(max_depth, len(stack))