Problem: 1614. 括号的最大嵌套深度耗时100%栈只存放左括号右括号pop且不放入栈的最大深度就是答案Codeclass Solution { public: int maxDepth(string s) { stackchar tk; int n s.size(), mx 0; char ch; for(int i 0; i n; i) { ch s[i]; if(ch() { tk.push((); } else if(ch)) { tk.pop(); } mx max(mx, (int)tk.size()); } return mx; } };