From 55b2990fef43df14f4e5d312a6f501252e7a4ae0 Mon Sep 17 00:00:00 2001 From: s0___0k <61587396+s0ooo0k@users.noreply.github.com> Date: Sat, 30 Aug 2025 20:43:49 +0900 Subject: [PATCH 1/2] Add valid parentheses Solution - s0ooo0k --- valid-parentheses/s0ooo0k.java | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 valid-parentheses/s0ooo0k.java diff --git a/valid-parentheses/s0ooo0k.java b/valid-parentheses/s0ooo0k.java new file mode 100644 index 000000000..4112cef14 --- /dev/null +++ b/valid-parentheses/s0ooo0k.java @@ -0,0 +1,26 @@ +class Solution { + public boolean isValid(String s) { + Deque stack = new ArrayDeque<>(); + + for(char c : s.toCharArray()) { + if(c == '(' || c=='{' || c=='[') { + stack.push(c); + } + if(c == ')') { + if(stack.isEmpty() || stack.peek() != '(') return false; + stack.pop(); + } + if(c == '}') { + if(stack.isEmpty() || stack.peek() != '{') return false; + stack.pop(); + } + if(c == ']') { + if(stack.isEmpty() || stack.peek() != '[') return false; + stack.pop(); + } + } + return stack.isEmpty(); + } +} + + From 02dab0e24e32cfadf530dc31aac842dbf2e75e86 Mon Sep 17 00:00:00 2001 From: s0___0k <61587396+s0ooo0k@users.noreply.github.com> Date: Sat, 30 Aug 2025 20:44:22 +0900 Subject: [PATCH 2/2] Add container with most water Solution = s0ooo0k --- container-with-most-water/s0ooo0k.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 container-with-most-water/s0ooo0k.java diff --git a/container-with-most-water/s0ooo0k.java b/container-with-most-water/s0ooo0k.java new file mode 100644 index 000000000..efeae703e --- /dev/null +++ b/container-with-most-water/s0ooo0k.java @@ -0,0 +1,21 @@ +class Solution { + public int maxArea(int[] height) { + int left=0; + int right=height.length-1; + int max=0; + + while(left