---
# System prepended metadata

title: 1614. Maximum Nesting Depth of the Parentheses
tags: [Leetcode, FaceBook, Bloomberg, Easy, Parentheses]

---

# 1614. Maximum Nesting Depth of the Parentheses
###### tags: `Leetcode` `Bloomberg` `Parentheses` `Easy` `FaceBook`
Link: https://leetcode.com/problems/maximum-nesting-depth-of-the-parentheses/
## 思路
过于简单了
直接看code吧
## Code
```python=
class Solution:
    def maxDepth(self, s: str) -> int:
        maxScore = 0
        currScore = 0
        for i, c in enumerate(s):
            if c == '(':
                currScore += 1
                maxScore = max(maxScore, currScore)
            elif c == ')':
                currScore -= 1
        return maxScore
```
```java=
class Solution {
    public int maxDepth(String s) {
        int curr = 0;
        int ans = 0;
        for(int i = 0;i < s.length();i++){
            if(s.charAt(i)=='('){
                curr++;
                if(ans < curr) ans = curr;
            }
            else if(s.charAt(i)==')'){
                curr--;
            }
        }
        return ans;
    }
}
```