> For the complete documentation index, see [llms.txt](https://cai-sen-se.gitbook.io/leetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cai-sen-se.gitbook.io/leetcode/1001-2000/1614.-kuo-hao-de-zui-da-qian-tao-shen-du.md).

# 1614.括号的最大嵌套深度

[原题](https://leetcode-cn.com/problems/maximum-nesting-depth-of-the-parentheses/)

## 模拟

根据题意，其实就是求最大的连续左括号的数量（跳过普通字符，且与 `)` 抵消后），只需要边遍历边统计即可。

```python
class Solution:
    def maxDepth(self, s: str) -> int:
        res = 0
        cnt = 0
        for c in s:
            if c == '(':
                cnt += 1
            elif c == ')':
                cnt -= 1
            res = max(res, cnt)
        return res
```
