public boolean isValid(String s) {
        List<Character> stack = new LinkedList<>();

        for (int i = 0; i < s.length(); i ++) {
            char c = s.charAt(i);

            if (c == '(' || c == '{' || c == '[') {
                stack.add(0, c);
            } else if (c == ')' || c == '}' || c == ']') {
                if (stack.isEmpty() || !match(stack.remove(0), c)) {
                    return false;
                }
            }
        }

        return stack.isEmpty();
    }