Skip to content

Commit

Permalink
Fied validParentheses kdn251#125
Browse files Browse the repository at this point in the history
  • Loading branch information
YatharthBhargava committed Feb 13, 2022
1 parent a70c225 commit a524ded
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions leetcode/string/ValidParentheses.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ public boolean isValid(String s) {
for(int i = 0; i < s.length(); i++) {
if(s.charAt(i) == '(' || s.charAt(i) == '[' || s.charAt(i) == '{') {
stack.push(s.charAt(i));
} 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();
} else {
return false;
Expand Down

0 comments on commit a524ded

Please sign in to comment.