Maximum Nesting Depth of the Parentheses
<-E 1614> Maximum Nesting Depth of the Parentheses
class Solution {
public:
int maxDepth(string s) {
int ans = 0;
int check = 0;
for(auto i : s) {
if(i == '(') {
check++;
}
if(i == ')') {
check--;
}
if(check > ans) {
ans = check;
}
}
return ans;
}
};