title: Maximum Possible Difference Two Subsets Array
signature: class Solution {
  
      public int MaximumPossibleDifferenceTwoSubsetsArray(List<int> arr, int n) {
test_code: using System;
  using System.Numerics;
  using System.Diagnostics;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Security.Cryptography;
  using System.Web.UI;
  using System.Web.Script.Serialization;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  namespace EvaluatePrediction {
      class TestRunner {
          public bool ValidateSolution(int actual, int expected){
              return new JavaScriptSerializer().Serialize(actual) == new JavaScriptSerializer().Serialize(expected);
          }
  
          public string driver(List<int> arr, int n, int expected){
              try{
                PLACEHOLDER_CLS_NAME solution_cls = new PLACEHOLDER_CLS_NAME();
                int pred_result = solution_cls.PLACEHOLDER_FN_NAME(arr, n); 
                if (ValidateSolution(
                      pred_result,
                      expected)){
                  return "PASSED";
                }
                return "FAILED";
              } 
              catch (Exception exception_obj)
              {
                return exception_obj.GetType().FullName;
              }
          }
          static void Main(string[] args) {
              TestRunner runner = new TestRunner();
              String result;
              result = runner.driver(
                  new List<int>{5, 14, 15, 21, 0, 0, 42, 0, 0, 0, 0, 48, 0, 0, 53, 60, 62, 69, 69, 79, 82, 86, 96}, 15, 
                  198
              );
              Console.WriteLine(string.Format(
                  "TEST-0...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{-54, 0, -22, 94, 58, 0, -12, 84, 0, 0, -34, 16, -10, -32, 50, -78, 68, -52, -64, 66, 0, 0, -38, -18, -84, -66, -36, 64, -12, 44, 48, 8, 42}, 28, 
                  1100
              );
              Console.WriteLine(string.Format(
                  "TEST-1...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{0, 0, 0, 1}, 2, 
                  0
              );
              Console.WriteLine(string.Format(
                  "TEST-2...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{63, 49, 18, 36, 21, 30, 45, 87}, 6, 
                  217
              );
              Console.WriteLine(string.Format(
                  "TEST-3...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{-96, 0, 0, -72, -62, -56, -52, -44, 0, 0, -28, -22, -20, -12, 0, 0, -2, 2, 2, 4, 36, 44, 46, 50, 50, 54, 66, 92}, 18, 
                  468
              );
              Console.WriteLine(string.Format(
                  "TEST-4...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0}, 34, 
                  1
              );
              Console.WriteLine(string.Format(
                  "TEST-5...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{1, 2, 8, 12, 0, 0, 14, 17, 18, 27, 28, 31, 34, 37, 38, 42, 43, 45, 49, 52, 53, 0, 0, 58, 62, 66, 71, 74, 87, 93, 96, 99}, 25, 
                  671
              );
              Console.WriteLine(string.Format(
                  "TEST-6...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{0, -28, -30, 86, 0, -80, 76, -2, 28, 0, 0, 84, 0, 0, -88, 0, 42, 16, 0, 0, 78, -8, -46, -6, 0, 0, 0, -12, -32, -72, 84, -82, 76, -84, 80, -50, 90, -50, -14, -82, 78, 48, -10, 86, 34, -20, -76, 58}, 28, 
                  710
              );
              Console.WriteLine(string.Format(
                  "TEST-7...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{0, 1}, 1, 
                  0
              );
              Console.WriteLine(string.Format(
                  "TEST-8...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{83, 86, 57, 18, 98, 52, 1, 37, 11, 49, 10, 67, 2, 60, 30, 42, 8, 97, 25, 55, 5, 75, 9, 67}, 16, 
                  703
              );
              Console.WriteLine(string.Format(
                  "TEST-9...{0}",
                  result)
              );
          }
      }
  }
  
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 );
  }