@@ -0,0 +1,1797 @@
+package main.algorithm.leetcode;%0A%0Aimport org.junit.Test;%0A%0Aimport java.util.ArrayDeque;%0A%0A/**%0A * Title : main.algorithm.leetcode %3Cbr%3E%0A * Company : %E5%8C%97%E4%BA%AC%E5%8D%8E%E5%AE%87%E5%85%83%E5%85%B8%E4%BF%A1%E6%81%AF%E6%9C%8D%E5%8A%A1%E6%9C%89%E9%99%90%E5%85%AC%E5%8F%B8 %3Cbr%3E%0A * Description :%0A *   %3Cp%3E Runtime: 1 ms, faster than 99.29%25 of Java online submissions for Valid Parentheses.%0A *   %3Cp%3E Memory Usage: 35.4 MB, less than 37.18%25 of Java online submissions for Valid Parentheses.%0A * @author chile%0A * @version 1.0%0A * @date 2019/4/30 11:24%0A */%0Apublic class ValidParentheses %7B%0A%0A    class Solution %7B%0A        public boolean isValid(String s) %7B%0A            if (s == null %7C%7C s.length() == 0) %7B%0A                return true;%0A            %7D%0A%0A            boolean result = false;%0A            ArrayDeque%3CCharacter%3E stack = new ArrayDeque%3C%3E();%0A            char%5B%5D chars = s.toCharArray();%0A            for (char c : chars) %7B%0A                if (indexOf(c) %3C 3) %7B%0A                    stack.addFirst(c);%0A                %7D else %7B%0A                    if (!stack.isEmpty() && indexOf(c) - indexOf(stack.getFirst()) == 3) %7B%0A                        stack.removeFirst();%0A                    %7D else %7B%0A                        return result;%0A                    %7D%0A                %7D%0A            %7D%0A%0A            return stack.isEmpty();%0A        %7D%0A%0A        public int indexOf(char c) %7B%0A            if (c == '(') %7B%0A                return 0;%0A            %7D%0A            if (c == '%5B') %7B%0A                return 1;%0A            %7D%0A            if (c == '%7B') %7B%0A                return 2;%0A            %7D%0A            if (c == ')') %7B%0A                return 3;%0A            %7D%0A            if (c == '%5D') %7B%0A                return 4;%0A            %7D%0A            if (c == '%7D') %7B%0A                return 5;%0A            %7D%0A            return -1;%0A        %7D%0A    %7D%0A%0A    @Test%0A    public void test1() %7B%0A        assert new Solution().isValid(%22()%7B%7D%5B%5D%22) == true;%0A    %7D%0A%0A%7D%0A

valid parentheses