title: Minimum Sum Two Numbers Formed Digits Array
signature: long long minimumSumTwoNumbersFormedDigitsArray(vector<int> arr, int n) {
test_code: #include <algorithm>
  #include <assert.h>
  #include <cstdlib>
  #include <iostream>
  #include <map>
  #include <set>
  #include <string>
  #include <tuple> 
  #include <unordered_map>
  #include <vector>
  #include <math.h>
  #include <cmath>
  #include <bits/stdc++.h>
  #include <numeric>
  #include <functional>
  
  using namespace std;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  bool validateSolution(long long actual, long long expected){
      return actual == expected;
  }
  
  string driver(vector<int> arr, int n, long long expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(arr, n), expected)){
              return "PASSED";
          }
          return "FAILED";
      }
      catch (const std::overflow_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::runtime_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::exception& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (...)
      {
          return "UNK_ERROR";
      }
  }
  
  int main() {
      string result = "";
  
      result = driver({3, 4, 5, 10, 14, 16, 18, 42, 43, 43, 45, 46, 51, 52, 53, 58, 61, 66, 79, 81, 82, 84}, 19, 4183488835); 
      cout << "TEST-" << 0 << "..."
           <<  result
           << "\n";
  
      result = driver({-90, -86, -76, -50, -46, -30, -26, -22, -22, -20, -2, -2, 8, 22, 32, 40, 48, 48, 56, 58, 60, 76, 82, 82, 94, 98}, 25, -107220607602444); 
      cout << "TEST-" << 1 << "..."
           <<  result
           << "\n";
  
      result = driver({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}, 23, 1222222); 
      cout << "TEST-" << 2 << "..."
           <<  result
           << "\n";
  
      result = driver({45, 79}, 1, 45); 
      cout << "TEST-" << 3 << "..."
           <<  result
           << "\n";
  
      result = driver({-90, -68, -38, -34, -4, 6, 10, 28, 48, 52, 54, 68, 88, 90}, 11, -10095534); 
      cout << "TEST-" << 4 << "..."
           <<  result
           << "\n";
  
      result = driver({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 22, 122222); 
      cout << "TEST-" << 5 << "..."
           <<  result
           << "\n";
  
      result = driver({4, 8, 8, 23, 26, 27, 30, 42, 44, 55, 59, 64, 67, 69, 74, 77, 82, 82, 87, 96, 97}, 17, 615688689); 
      cout << "TEST-" << 6 << "..."
           <<  result
           << "\n";
  
      result = driver({-98, -98, -86, -82, -76, -76, -66, -64, -62, -60, -48, -46, -42, -36, -36, -32, -28, -18, -18, -4, 0, 0, 2, 4, 10, 18, 30, 46, 50, 52, 62, 70, 72, 76, 80, 88, 88, 94, 96}, 32, -214463225281903248); 
      cout << "TEST-" << 7 << "..."
           <<  result
           << "\n";
  
      result = driver({0, 0, 0, 0, 0, 0, 1, 1, 1, 1}, 6, 0); 
      cout << "TEST-" << 8 << "..."
           <<  result
           << "\n";
  
      result = driver({7, 8, 9, 9, 14, 14, 16, 17, 22, 24, 32, 32, 36, 38, 42, 42, 43, 45, 47, 53, 54, 56, 58, 58, 61, 63, 64, 68, 69, 69, 71, 71, 71, 72, 73, 74, 75, 82, 86, 86, 87, 90, 96, 97, 98}, 25, 8964536953959); 
      cout << "TEST-" << 9 << "..."
           <<  result
           << "\n";
  
      return 0;
  }
source_py: def minimum_sum_two_numbers_formed_digits_array(arr, n):
      arr.sort()
      a = 0
      b = 0
      for i in range(n):
          if ((i % 2) != 0):
              a = ((a * 10) + arr[i])
          else:
              b = ((b * 10) + arr[i])
      return (a + b)
source_cpp: int minimum_sum_two_numbers_formed_digits_array(vector<int> arr, int n) {
    sort(arr.begin(), arr.end());
    int a = 0, b = 0;
    for ( int i = 0;
    i < n;
    i ++ ) {
      if ( i & 1 ) a = a * 10 + arr [ i ];
      else b = b * 10 + arr [ i ];
    }
    return a + b;
  }