1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-09-19 17:56:55 +02:00
LeetCode/cs/maximum-nesting-depth-of-the-parentheses.cs
2024-04-04 23:08:57 +02:00

21 lines
435 B
C#

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;
}
}