Skip to content

Commit 1b23fbb

Browse files
committed
Time: 0 ms (100.00%), Space: 6.3 MB (20.90%) - LeetHub
1 parent c23f7ed commit 1b23fbb

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public:
3+
int maxDepth(string s) {
4+
stack<char> st;
5+
int maxDepth = 0;
6+
for(auto ch: s){
7+
if(ch=='('){
8+
st.push(ch);
9+
}
10+
else if(ch==')'){
11+
maxDepth = st.size() > maxDepth ? st.size() : maxDepth;
12+
st.pop();
13+
}
14+
}
15+
return maxDepth;
16+
}
17+
};

0 commit comments

Comments
 (0)