@@ -0,0 +1,1274 @@
+package leetcode;%0A%0Aimport java.util.ArrayDeque;%0Aimport java.util.Deque;%0A%0Apublic class Task20 %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A        System.out.println(new Task20().isValid(%22()%22));%0A        System.out.println(new Task20().isValid(%22()%5B%5D%7B%7D%22));%0A        System.out.println(new Task20().isValid(%22(%5D%22));%0A        System.out.println(new Task20().isValid(%22(%5B)%5D%22));%0A        System.out.println(new Task20().isValid(%22%7B%5B%5D%7D%22));%0A        System.out.println(new Task20().isValid(%22%5B%22));%0A        System.out.println(new Task20().isValid(%22%5D%22));%0A    %7D%0A%0A    public boolean isValid(String s) %7B%0A        Deque%3CCharacter%3E stack = new ArrayDeque%3C%3E();%0A        for (int i = 0; i %3C s.length(); i++) %7B%0A            char c = s.charAt(i);%0A            if (c == '(' %7C%7C c == '%7B' %7C%7C c == '%5B') %7B%0A                stack.add(c);%0A            %7D else %7B%0A                char last = stack.isEmpty() ? '%5C0' : stack.removeLast();%0A                if (last == '(' && c == ')') %7B%0A                    continue;%0A                %7D%0A                if (last == '%7B' && c == '%7D') %7B%0A                    continue;%0A                %7D%0A                if (last == '%5B' && c == '%5D') %7B%0A                    continue;%0A                %7D%0A                return false;%0A            %7D%0A        %7D%0A        return stack.isEmpty();%0A    %7D%0A%7D%0A

Add Task20