@@ -0,0 +1,1035 @@
+// Given a string containing just the characters '(', ')', '%7B', '%7D', '%5B' and '%5D', determine if the input string is valid.%0A%0A// The brackets must close in the correct order, %22()%22 and %22()%5B%5D%7B%7D%22 are all valid but %22(%5D%22 and %22(%5B)%5D%22 are not.%0A%0Apublic class Solution %7B%0A    public boolean isValid(String s) %7B%0A    %09int len = s.length();%0A%0A    %09if(len == 0) return true;%0A%0A    %09Stack%3CCharacter%3E st = new Stack%3CCharacter%3E();%0A%0A    %09char%5B%5D chars = s.toCharArray();%0A%0A    %09for(char c : chars)%7B%0A    %09%09if(c == ')' %7C%7C c == '%7D' %7C%7C c == '%5D')%7B%0A    %09%09%09if(st.isEmpty())%7B%0A    %09%09%09%09return false;%0A    %09%09%09%7Delse%7B%0A    %09%09%09%09if(st.pop() == pair(c))%7B%0A    %09%09%09%09%09continue;%0A    %09%09%09%09%7Delse%7B%0A    %09%09%09%09%09return false;%0A    %09%09%09%09%7D%0A    %09%09%09%7D %0A    %09%09%7Delse%7B%0A    %09%09%09st.push(c);%0A    %09%09%7D%0A    %09%7D%0A%0A    %09if(st.isEmpty())%7B%0A    %09%09return true;%0A    %09%7D%0A%0A    %09return false;%0A    %7D%0A%0A    public char pair(char c)%7B%0A    %09char pair = '';%0A    %09switch(c)%7B%0A    %09%09case ')':%0A%09%09%09%09pair = '(';%0A%09%09%09%09break;%0A%09%09%09case '%5D':%0A%09%09%09%09pair = '%5B';%0A%09%09%09%09break;%0A%09%09%09case '%7D':%0A%09%09%09%09pair = '%7B';%0A%09%09%09%09break;%0A    %09%7D%0A%0A    %09return pair;%0A    %7D%0A%7D

add valid parentheses solution