title: Maximum Possible Difference Two Subsets Array
signature: maximum_possible_difference_two_subsets_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, 14L, 15L, 21L, 0L, 0L, 42L, 0L, 0L, 0L, 0L, 48L, 0L, 0L, 53L, 60L, 62L, 69L, 69L, 79L, 82L, 86L, 96L), 15L, 
          198L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          list(-54L, 0L, -22L, 94L, 58L, 0L, -12L, 84L, 0L, 0L, -34L, 16L, -10L, -32L, 50L, -78L, 68L, -52L, -64L, 66L, 0L, 0L, -38L, -18L, -84L, -66L, -36L, 64L, -12L, 44L, 48L, 8L, 42L), 28L, 
          1100L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          list(0L, 0L, 0L, 1L), 2L, 
          0L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          list(63L, 49L, 18L, 36L, 21L, 30L, 45L, 87L), 6L, 
          217L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          list(-96L, 0L, 0L, -72L, -62L, -56L, -52L, -44L, 0L, 0L, -28L, -22L, -20L, -12L, 0L, 0L, -2L, 2L, 2L, 4L, 36L, 44L, 46L, 50L, 50L, 54L, 66L, 92L), 18L, 
          468L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 0L, 1L, 1L, 1L, 0L), 34L, 
          1L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          list(1L, 2L, 8L, 12L, 0L, 0L, 14L, 17L, 18L, 27L, 28L, 31L, 34L, 37L, 38L, 42L, 43L, 45L, 49L, 52L, 53L, 0L, 0L, 58L, 62L, 66L, 71L, 74L, 87L, 93L, 96L, 99L), 25L, 
          671L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          list(0L, -28L, -30L, 86L, 0L, -80L, 76L, -2L, 28L, 0L, 0L, 84L, 0L, 0L, -88L, 0L, 42L, 16L, 0L, 0L, 78L, -8L, -46L, -6L, 0L, 0L, 0L, -12L, -32L, -72L, 84L, -82L, 76L, -84L, 80L, -50L, 90L, -50L, -14L, -82L, 78L, 48L, -10L, 86L, 34L, -20L, -76L, 58L), 28L, 
          710L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          list(0L, 1L), 1L, 
          0L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          list(83L, 86L, 57L, 18L, 98L, 52L, 1L, 37L, 11L, 49L, 10L, 67L, 2L, 60L, 30L, 42L, 8L, 97L, 25L, 55L, 5L, 75L, 9L, 67L), 16L, 
          703L
      )))
  
  }
  
  main()
source_py: def maximum_possible_difference_two_subsets_array(arr, n):
      SubsetSum_1 = 0
      SubsetSum_2 = 0
      for i in range(0, n):
          isSingleOccurance = True
          for j in range((i + 1), n):
              if (arr[i] == arr[j]):
                  isSingleOccurance = False
                  arr[i] = arr[j] = 0
                  break
          if (isSingleOccurance == True):
              if (arr[i] > 0):
                  SubsetSum_1 += arr[i]
              else:
                  SubsetSum_2 += arr[i]
      return abs((SubsetSum_1 - SubsetSum_2))
source_cpp: int maximum_possible_difference_two_subsets_array(vector<int> arr, int n) {
    int SubsetSum_1 = 0, SubsetSum_2 = 0;
    for ( int i = 0;
    i <= n - 1;
    i ++ ) {
      bool isSingleOccurance = true;
      for ( int j = i + 1;
      j <= n - 1;
      j ++ ) {
        if ( arr [ i ] == arr [ j ] ) {
          isSingleOccurance = false;
          arr [ i ] = arr [ j ] = 0;
          break;
        }
      }
      if ( isSingleOccurance ) {
        if ( arr [ i ] > 0 ) SubsetSum_1 += arr [ i ];
        else SubsetSum_2 += arr [ i ];
      }
    }
    return abs ( SubsetSum_1 - SubsetSum_2 );
  }