Description


Submission
class Solution {
public:
int maxDepth(string s) {
stack<char> stk;
int ret = 0, depth = 0;
for(auto c: s) {
if(c == ')') {
// while(s.top() != '(') stk.pop();
stk.pop(); // pop '('
depth--;
}
if(c == '(') {
stk.push('(');
depth++;
ret = max(ret, depth);
}
}
return ret;
}
};
