title: Maximum Triplet Sum Array 1
signature: function maximum_triplet_sum_array_1(arr, n)
test_code: 
  
  -- SOLUTION CODE
  -- ============================================
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  function isCorrect(actual, expected)
      if type(expected) ~= type(actual) then
          return false
      end
      
      if type(expected) == 'table' then
          for k,v_expected in pairs(expected) do
              
              if actual[k] == nil then
                  return false
              end
              local v_actual = actual[k]
              if not isCorrect(v_actual, v_expected) then
                  return false
              end
              actual[k]=nil
          end
      
          if next(actual) then 
              return false
          end
          return true
      else
          return actual == expected
      end
  end
  
  function validateSolution(actual, expected)
      return isCorrect(actual,expected)
  end
  
  function driver(arr, n, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(arr, n) 
      end)
      if status then
          if validateSolution(exec_result,expected) then
              return "PASSED"
          end
          return "FAILED"
      else
          return string.format("ERROR=%s",string.gsub(error_msg,".*:[%d]+: ",""))
      end
  end
      
  function main()
      result = driver({6, 8, 18, 18, 27, 33, 33, 38, 42, 43, 44, 47, 52, 58, 64, 65, 67, 68, 71, 75, 85, 89, 91, 94, 94, 95, 95}, 26, 283)
      print(string.format("TEST-0...%s",result))
  
      result = driver({-88, -84, -82, -58, -12, 18, 24, 24, 28, 30, 34, 44, 92, 94}, 8, 66)
      print(string.format("TEST-1...%s",result))
  
      result = driver({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1}, 15, 2)
      print(string.format("TEST-2...%s",result))
  
      result = driver({1, 2, 4, 5, 9, 11, 12, 15, 16, 18, 18, 21, 23, 25, 25, 26, 27, 28, 31, 34, 35, 47, 51, 55, 63, 63, 66, 67, 70, 70, 72, 73, 73, 75, 76, 79, 81, 84, 87, 87, 92, 94, 95}, 37, 236)
      print(string.format("TEST-3...%s",result))
  
      result = driver({-86, -86, -78, -56, -24, -14, -10, -6, 12, 12, 18, 22, 22, 26, 50, 50, 72, 78, 94}, 9, -4)
      print(string.format("TEST-4...%s",result))
  
      result = driver({0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1}, 9, 2)
      print(string.format("TEST-5...%s",result))
  
      result = driver({2, 13, 17, 19, 20, 23, 28, 28, 29, 40, 45, 51, 52, 58, 58, 68, 70, 75, 79, 81, 92, 96, 97}, 15, 168)
      print(string.format("TEST-6...%s",result))
  
      result = driver({-78, -62, -46, -36, -20, -4, 4, 6, 6, 40, 50, 52, 64, 76, 94}, 13, 166)
      print(string.format("TEST-7...%s",result))
  
      result = driver({0, 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, 1, 1, 1, 1}, 27, 3)
      print(string.format("TEST-8...%s",result))
  
      result = driver({3, 3, 4, 5, 6, 7, 11, 11, 14, 15, 17, 22, 25, 32, 33, 34, 35, 42, 44, 44, 52, 57, 58, 66, 70, 89}, 13, 64)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
source_py: def maximum_triplet_sum_array_1(arr, n):
      arr.sort()
      return ((arr[(n - 1)] + arr[(n - 2)]) + arr[(n - 3)])
source_cpp: int maximum_triplet_sum_array_1(vector<int> arr, int n) {
    sort(arr.begin(), arr.end());
    return arr [ n - 1 ] + arr [ n - 2 ] + arr [ n - 3 ];
  }