Skip to content

Commit d2eaf0e

Browse files
committed
Solution as on 18-02-2022 08:29 am
1 parent b3798fa commit d2eaf0e

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// 1614.✅ Maximum Nesting Depth of the Parentheses
2+
3+
class Solution
4+
{
5+
public:
6+
int maxDepth(string s)
7+
{
8+
9+
int cnt = 0;
10+
11+
if (s.size() == 0)
12+
return 0;
13+
int m = INT_MIN;
14+
15+
for (auto i : s)
16+
{
17+
if (i == '(')
18+
++cnt;
19+
if (i == ')')
20+
--cnt;
21+
22+
m = max(m, cnt);
23+
}
24+
return m;
25+
}
26+
};

0 commit comments

Comments
 (0)