@@ -0,0 +1,1760 @@
+//https://www.hackerrank.com/challenges/balanced-parentheses%0Aimport java.io.*;%0Aimport java.util.*;%0A%0Apublic class Solution %7B%0A    public static void main(String%5B%5D args) throws IOException %7B%0A        final StringBuffer sb = new StringBuffer();%0A        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));%0A        %0A        //For each test case...%0A        for(short T = Short.parseShort(br.readLine()); T %3E 0; --T)%7B%0A            %0A            //Get input%0A            final char%5B%5D S = br.readLine().toCharArray();%0A            %0A            //Print output%0A            sb.append((isBalanced(S)) ? %22YES%5Cn%22 : %22NO%5Cn%22);%0A        %7D%0A        System.out.print(sb);%0A    %7D%0A    %0A    private static boolean isBalanced(final char%5B%5D A)%7B%0A        final Deque%3CCharacter%3E stack = new ArrayDeque%3CCharacter%3E();%0A        %0A        //For each character...%0A        for(int i = 0, n = A.length; i %3C n; ++i)%7B%0A            %0A            //Get character%0A            final char c = A%5Bi%5D;%0A            %0A            //Check if opening a parenthesis%0A            if(c == '%7B' %7C%7C c == '%5B' %7C%7C c == '(')%7B%0A                stack.push(c);%0A                continue;%0A            %7D%0A            %0A            //Check if closing without any open parenthesis%0A            if(stack.isEmpty())%7B%0A                return false;%0A            %7D%0A            %0A            //Check if closing without matching open parenthesis%0A            //Remove parenthesis from stack if closed correctly%0A            final char p = stack.pop();%0A            if((c == '%7D' && p != '%7B') %7C%7C %0A               (c == '%5D' && p != '%5B') %7C%7C %0A               (c == ')' && p != '('))%7B%0A                return false;%0A            %7D%0A        %7D%0A        %0A        //Check if all parentheses closed correctly%0A        return stack.isEmpty();%0A    %7D%0A%7D%0A

Create balanced-parentheses.java