diff --git a/E_1614_MaximumNestingDepthoftheParentheses.java b/E_1614_MaximumNestingDepthoftheParentheses.java new file mode 100644 index 0000000..655e791 --- /dev/null +++ b/E_1614_MaximumNestingDepthoftheParentheses.java @@ -0,0 +1,13 @@ +public class Solution { + public int maxDepth(String s) { + int depth = 0; + int max = 0; + for (int i = 0; i < s.length(); i++) { + if (s.charAt(i) == '(') depth++; + else if (s.charAt(i) == ')') depth--; + max = Math.max(depth, max); + } + return max; + + } +} \ No newline at end of file