diff --git a/Company/Airbnb/validParentheses.java b/Company/Airbnb/validParentheses.java index 4269f9c2..6bcf6349 100644 --- a/Company/Airbnb/validParentheses.java +++ b/Company/Airbnb/validParentheses.java @@ -22,19 +22,19 @@ public boolean isValid(String s) { } - else if(s.charAt(i) == ')' && !stack.isEmpty() && stack.peek() == ')') { + else if(s.charAt(i) == ')' && !stack.isEmpty() && stack.peek() == '(') { stack.pop(); } - else if(s.charAt(i) == ']' && !stack.isEmpty() && stack.peek() == ']') { + else if(s.charAt(i) == ']' && !stack.isEmpty() && stack.peek() == '[') { stack.pop(); } - else if(s.charAt(i) == '}' && !stack.isEmpty() && stack.peek() == '}') { + else if(s.charAt(i) == '}' && !stack.isEmpty() && stack.peek() == '{') { stack.pop(); @@ -52,4 +52,4 @@ else if(s.charAt(i) == '}' && !stack.isEmpty() && stack.peek() == '}') { } -} \ No newline at end of file +}