title: Check Exist Two Elements Array Whose Sum Equal Sum Rest Array
signature: pub fn check_exist_two_elements_array_whose_sum_equal_sum_rest_array(arr: Vec<i32>, n: i32) -> bool {
test_code: use std::collections::HashMap;
  use std::collections::HashSet;
  use std::cmp::*;
  use std::collections::*;
  use std::fmt::*; 
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  pub fn validate_solution(actual: bool, expected: bool)->bool{
  return actual==expected
  }
  pub fn driver(arr: Vec<i32>, n: i32, expected: bool)->String{
      if validate_solution(PLACEHOLDER_FN_NAME(arr, n), expected) {
        return "PASSED".to_string();
      };
      return "FAILED".to_string();
  
  }
  
  fn main() {
      println!("TEST-0...{}", driver(
        Vec::from([2, 11, 5, 1, 4, 7]), 6, 
        false
      ));
      
      println!("TEST-1...{}", driver(
        Vec::from([2, 4, 2, 1, 11, 15]), 6, 
        false
      ));
      
      println!("TEST-2...{}", driver(
        Vec::from([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
      ));
      
      println!("TEST-3...{}", driver(
        Vec::from([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
      ));
      
      println!("TEST-4...{}", driver(
        Vec::from([-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
      ));
      
      println!("TEST-5...{}", driver(
        Vec::from([1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1]), 10, 
        false
      ));
      
      println!("TEST-6...{}", driver(
        Vec::from([21, 26, 26, 27, 61, 62, 96]), 6, 
        false
      ));
      
      println!("TEST-7...{}", driver(
        Vec::from([-54, 86, 20, 26]), 3, 
        false
      ));
      
      println!("TEST-8...{}", driver(
        Vec::from([0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), 4, 
        false
      ));
      
      println!("TEST-9...{}", driver(
        Vec::from([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
      ));
      
  }
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;
  }