From 18f1484bee12a7b55224e10d1bef303394db3196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C5=9F=C4=B1nsu=20Ar=C4=B1c=C4=B1?= Date: Tue, 18 Jan 2022 23:29:44 +0300 Subject: [PATCH] 1614 --- E_1614_MaximumNestingDepthoftheParentheses.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 E_1614_MaximumNestingDepthoftheParentheses.java 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