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 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(); + } +} + +