title: Check if sum of left side of array equal to right side of array in o(n)
body: <p>I was given an array of numbers (integer) and I need to return the element if the sum of numbers in his right side equals to the sum of numbers in his left size in o(n).</p>
  
  <p>For example the array {1,2,2,9,3,2}
  the program should print 9 because 1+2+2 = 5 and 3+2=5</p>
  
  <p>I attached my code but it's not o(n) complexity.
  appreciate your help.</p>
  
  <p>Thanks.</p>
  
  <pre><code>public class Program {
      public static void checkIfEqualOption1(int[] arr){
          int sumRight = 0;
          int sumLeft=0;
          //sumRight+=numbers[0];
          for (int i=0; i &lt; arr.length; i++){
              if (i&gt;0){
                  sumRight+=arr[i-1];
                  for (int j=i+1; j&lt;arr.length; j++){
                      sumLeft+=arr[j];
                  }
                  if (sumRight==sumLeft){
                      System.out.println("\nFound = "+arr[i]);
                      break;
                  }
              }
          }
  
      }
  
      public static void print(int[] arr){
          for (int i=0; i &lt; arr.length; i++){
              System.out.print(arr[i] + " ");
          }
      }
      public static void main(String[] args) {
          // TODO Auto-generated method stub
          System.out.println("Hi");
          int[] numbers = {1,2,2,9,3,2};
          System.out.println("Array numbers:");
          for (int i=0; i &lt; numbers.length; i++){
              System.out.print(numbers[i] + " ");
          }
          System.out.println("\n");
          checkIfEqualOption1(numbers);
      }
  }
  </code></pre>