1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-11-09 15:59:06 +01:00

cs: add «1614. Maximum Nesting Depth of the Parentheses»

Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
Matej Focko 2024-04-04 23:08:57 +02:00
parent 49defb257e
commit e1f7a646ae
Signed by: mfocko
GPG key ID: 7C47D46246790496

View file

@ -0,0 +1,21 @@
public class Solution {
public int MaxDepth(string s) {
int maxDepth = 0;
int open = 0;
foreach (var c in s) {
switch (c) {
case '(':
++open;
break;
case ')':
--open;
break;
}
maxDepth = Math.Max(maxDepth, open);
}
return maxDepth;
}
}