https://leetcode-cn.com/problems/valid-parentheses/
class Solution {public boolean isValid(String s) {LinkedList<Character> stack = new LinkedList<>();// 遍历字符串中所有字符,依次判断for (int i = 0; i < s.length(); i++) {char c = s.charAt(i);// 判断当前是左/右括号if (c == '(') {stack.push(')');} else if (c == '[') {stack.push(']');} else if (c == '{') {stack.push('}');} else {if (stack.isEmpty() || stack.pop() != c) return false;}}return stack.isEmpty();}}
