mirror of
https://gitlab.com/mfocko/LeetCode.git
synced 2024-11-14 01:49:41 +01:00
22 lines
435 B
C#
22 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;
|
||
|
}
|
||
|
}
|