@@ -0,0 +1,1654 @@
+package hacker_rank;%0A%0Aimport java.io.*;%0Aimport java.util.*;%0A%0A/*%0A    Solution: Sherlock and the array%0A*/%0A%0Apublic class SherlockAndArray %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A        %0A        Scanner in = new Scanner(System.in);%0A        %0A        int T = in.nextInt();%0A        %0A        // Fro each test case%0A        for(int t = 0; t%3CT; t++)%7B%0A            %0A            int N = in.nextInt();    // Number of elements%0A            %0A            int  A%5B%5D = new int%5BN%5D;   // Array%0A            %0A            // Read array%0A            for(int i=0;i%3CN;i++)%0A                A%5Bi%5D = in.nextInt();%0A                       %0A            %0A            int sumL = 0, sumR = 0;    // Sum of left and right sides%0A            %0A            // for index 0, sumR would be sum of indices 1 to N-1%0A            for(int i=1;i%3CN;i++)%0A                sumR+=A%5Bi%5D;%0A            %0A            // For index 0 through N-1%0A            int i=0;%0A            for(i=0;i%3CN;i++)%7B%0A                %0A                // Break if sumL equals sumR%0A                if(sumL == sumR)%0A                    break;%0A                %0A                // Otherwise, add current index (i) value  to sumL and subtract (i+1) index value from R%0A                sumL+=A%5Bi%5D;%0A                %0A                if(i+1%3CA.length)    // Avoid index out of bound exception for boundary case%0A                   sumR-=A%5Bi+1%5D;%0A                %0A            %7D%0A            %0A            // If loop breaks due because of sumL = sumR condition, then i must be less than N.%0A            if(i%3CN)%0A                System.out.println(%22YES%22);%0A            else%0A                System.out.println(%22NO%22);%0A            %0A        %7D%0A        %0A    %7D%0A%7D

Solve Sherlock and Array