title: Find Sum Non Repeating Distinct Elements Array
signature: function findSumNonRepeatingDistinctElementsArray(arr, n) {
test_code: 
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function convertToString(value) {
      return JSON.stringify(value, function (key, val) {
          if (val instanceof Set) {
              return Array.from(val);
          } return val;});
  }
  
  function validateSolution(actual, expected){
      return convertToString(actual)===convertToString(expected);
  }
  
  function driver(arr, n, expected){
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(arr, n),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver([5, 6, 8, 10, 21, 22, 27, 32, 35, 36, 43, 44, 46, 48, 49, 55, 60, 61, 69, 69, 71, 72, 73, 78, 88, 94], 24, 971);
    console.log(`TEST-0...${result}`);
  
    result = driver([80, 94, 16, -74, 32, -64, -84, -66, -10], 6, 84);
    console.log(`TEST-1...${result}`);
  
    result = driver([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 27, 1);
    console.log(`TEST-2...${result}`);
  
    result = driver([99, 4, 96, 39, 39, 24, 15, 47, 25, 74, 7, 98, 88, 91, 62, 12, 31, 14, 48, 26, 37, 25, 11, 32, 34, 64, 72, 5, 80, 86, 6], 15, 769);
    console.log(`TEST-3...${result}`);
  
    result = driver([-86, -84, -84, -78, -78, -76, -74, -68, -66, -64, -60, -60, -56, -50, -42, -42, -38, -34, -32, -22, -16, -14, -10, -6, -6, 4, 4, 26, 36, 36, 54, 62, 64, 68, 70, 76, 76, 76, 84, 92, 92, 94, 96], 27, -972);
    console.log(`TEST-4...${result}`);
  
    result = driver([1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1], 25, 1);
    console.log(`TEST-5...${result}`);
  
    result = driver([3, 3, 5, 8, 32, 33, 35, 35, 42, 48, 67, 71, 71, 74, 77, 80, 94, 96, 96, 97], 19, 765);
    console.log(`TEST-6...${result}`);
  
    result = driver([-50, -18, -66, 76, -54, 96, 98, 26, 42, 64, -60], 9, 150);
    console.log(`TEST-7...${result}`);
  
    result = driver([0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 15, 1);
    console.log(`TEST-8...${result}`);
  
    result = driver([70, 21, 44, 82, 62, 41, 86], 3, 135);
    console.log(`TEST-9...${result}`);
  
    process.exit(0);
  };
  
  if (require.main === module) {
    main();
  }
source_py: def find_sum_non_repeating_distinct_elements_array(arr, n):
      s = set()
      sum = 0
      for i in range(n):
          if (arr[i] not in s):
              s.add(arr[i])
      for i in s:
          sum = (sum + i)
      return sum
source_cpp: int find_sum_non_repeating_distinct_elements_array(vector<int> arr, int n) {
    int sum = 0;
    unordered_set < int > s;
    for ( int i = 0;
    i < n;
    i ++ ) {
      if ( s . find ( arr [ i ] ) == s . end ( ) ) {
        sum += arr [ i ];
        s . insert ( arr [ i ] );
      }
    }
    return sum;
  }