title: Check Exist Two Elements Array Whose Sum Equal Sum Rest Array
signature: class Solution {
  
      public Boolean checkExistTwoElementsArrayWhoseSumEqualSumRestArray(ArrayList<Integer> arr, Integer n) {
source_py: def check_exist_two_elements_array_whose_sum_equal_sum_rest_array(arr, n):
      s = set()
      sum = 0
      for i in range(n):
          sum += arr[i]
      if ((sum % 2) != 0):
          return False
      sum = (sum / 2)
      for i in range(n):
          val = (sum - arr[i])
          if (arr[i] not in s):
              s.add(arr[i])
          if (val in s):
              print('Pair elements are', arr[i], 'and', int(val))
source_cpp: bool check_exist_two_elements_array_whose_sum_equal_sum_rest_array(vector<int> arr, int n) {
    int sum = 0;
    for ( int i = 0;
    i < n;
    i ++ ) sum += arr [ i ];
    if ( sum % 2 != 0 ) return false;
    sum = sum / 2;
    unordered_set < int > s;
    for ( int i = 0;
    i < n;
    i ++ ) {
      int val = sum - arr [ i ];
      if ( s . find ( val ) != s . end ( ) ) {
        return true;
      }
      s . insert ( arr [ i ] );
    }
    return false;
  }
question_info.extension: java
question_info.entry_fn_name: checkExistTwoElementsArrayWhoseSumEqualSumRestArray
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": null, "inputs": {"arr": [2, 11, 5, 1, 4, 7], "n": 6}}, {"idx": 1, "outputs": false, "inputs": {"arr": [2, 4, 2, 1, 11, 15], "n": 6}}, {"idx": 2, "outputs": null, "inputs": {"arr": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 13}}, {"idx": 3, "outputs": false, "inputs": {"arr": [69, 6, 24, 30, 75, 37, 61, 76, 19, 18, 90, 9, 49, 24, 58, 97, 18, 85, 24, 93, 71, 98, 92, 59, 75, 75, 75, 70, 35, 58, 50, 1, 64, 66, 33], "n": 18}}, {"idx": 4, "outputs": null, "inputs": {"arr": [-94, -94, -92, -74, -60, -58, -56, -44, -42, -40, -28, -14, 2, 4, 14, 20, 24, 28, 40, 42, 42, 66, 78, 78, 80, 82, 96], "n": 26}}, {"idx": 5, "outputs": false, "inputs": {"arr": [1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1], "n": 10}}, {"idx": 6, "outputs": false, "inputs": {"arr": [21, 26, 26, 27, 61, 62, 96], "n": 6}}, {"idx": 7, "outputs": null, "inputs": {"arr": [-54, 86, 20, 26], "n": 3}}, {"idx": 8, "outputs": null, "inputs": {"arr": [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 4}}, {"idx": 9, "outputs": null, "inputs": {"arr": [44, 35, 26, 15, 56, 6, 36, 53, 15, 66, 20, 53, 99, 96, 51, 12, 61, 19, 79, 40, 99, 42, 86, 8, 11, 54, 93, 46, 23, 47, 41, 26, 66, 5, 86, 52, 64, 51, 4, 21, 63, 14, 7, 53, 31, 8, 9, 63], "n": 31}}]
question_info.test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(ArrayList<Integer> arr, Integer n, Boolean expected){
          try{
              Driver driver = new Driver();
              if (driver.run(arr, n,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution(new ArrayList<>(Arrays.asList(2, 11, 5, 1, 4, 7)), 6, false);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(2, 4, 2, 1, 11, 15)), 6, false);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)), 13, false);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(69, 6, 24, 30, 75, 37, 61, 76, 19, 18, 90, 9, 49, 24, 58, 97, 18, 85, 24, 93, 71, 98, 92, 59, 75, 75, 75, 70, 35, 58, 50, 1, 64, 66, 33)), 18, false);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-94, -94, -92, -74, -60, -58, -56, -44, -42, -40, -28, -14, 2, 4, 14, 20, 24, 28, 40, 42, 42, 66, 78, 78, 80, 82, 96)), 26, false);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1)), 10, false);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(21, 26, 26, 27, 61, 62, 96)), 6, false);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-54, 86, 20, 26)), 3, false);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)), 4, false);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(44, 35, 26, 15, 56, 6, 36, 53, 15, 66, 20, 53, 99, 96, 51, 12, 61, 19, 79, 40, 99, 42, 86, 8, 11, 54, 93, 46, 23, 47, 41, 26, 66, 5, 86, 52, 64, 51, 4, 21, 63, 14, 7, 53, 31, 8, 9, 63)), 31, false);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(ArrayList<Integer> arr, Integer n, Boolean expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(arr, n),expected);
      }
      
      public boolean validateSolution(Boolean actual, Boolean expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: java __FILENAME__