title: Find Sum Non Repeating Distinct Elements Array
signature: find_sum_non_repeating_distinct_elements_array <- function(arr, n) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(arr, n, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(arr, n), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          list(5L, 6L, 8L, 10L, 21L, 22L, 27L, 32L, 35L, 36L, 43L, 44L, 46L, 48L, 49L, 55L, 60L, 61L, 69L, 69L, 71L, 72L, 73L, 78L, 88L, 94L), 24L, 
          971L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          list(80L, 94L, 16L, -74L, 32L, -64L, -84L, -66L, -10L), 6L, 
          84L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 27L, 
          1L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          list(99L, 4L, 96L, 39L, 39L, 24L, 15L, 47L, 25L, 74L, 7L, 98L, 88L, 91L, 62L, 12L, 31L, 14L, 48L, 26L, 37L, 25L, 11L, 32L, 34L, 64L, 72L, 5L, 80L, 86L, 6L), 15L, 
          769L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          list(-86L, -84L, -84L, -78L, -78L, -76L, -74L, -68L, -66L, -64L, -60L, -60L, -56L, -50L, -42L, -42L, -38L, -34L, -32L, -22L, -16L, -14L, -10L, -6L, -6L, 4L, 4L, 26L, 36L, 36L, 54L, 62L, 64L, 68L, 70L, 76L, 76L, 76L, 84L, 92L, 92L, 94L, 96L), 27L, 
          -972L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          list(1L, 1L, 1L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 1L), 25L, 
          1L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          list(3L, 3L, 5L, 8L, 32L, 33L, 35L, 35L, 42L, 48L, 67L, 71L, 71L, 74L, 77L, 80L, 94L, 96L, 96L, 97L), 19L, 
          765L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          list(-50L, -18L, -66L, 76L, -54L, 96L, 98L, 26L, 42L, 64L, -60L), 9L, 
          150L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 15L, 
          1L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          list(70L, 21L, 44L, 82L, 62L, 41L, 86L), 3L, 
          135L
      )))
  
  }
  
  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;
  }