[Algorithm] Leetcode Valid Parentheses

1 · Br · Nov. 29, 2021, midnight
Leetcode Valid Parentheses https://leetcode.com/problems/valid-parentheses/ Solution class Solution { public boolean isValid(String s) { Stack<Character> stack = new Stack<>(); for (char c : s.toCharArray()) { if (c == '(') { stack.add(')'); } else if (c == '[') { stack.add(']'); } else if (c == '{') { stack.add('}'); } else if (stack.isEmpty() || stack.pop() != c) { ...