title: Maximum Triplet Sum Array 1
signature: pub fn maximum_triplet_sum_array_1(arr: Vec<i32>, n: i32) -> i32 {
test_code: use std::collections::HashMap;
  use std::collections::HashSet;
  use std::cmp::*;
  use std::collections::*;
  use std::fmt::*; 
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  pub fn validate_solution(actual: i32, expected: i32)->bool{
  return actual==expected
  }
  pub fn driver(arr: Vec<i32>, n: i32, expected: i32)->String{
      if validate_solution(PLACEHOLDER_FN_NAME(arr, n), expected) {
        return "PASSED".to_string();
      };
      return "FAILED".to_string();
  
  }
  
  fn main() {
      println!("TEST-0...{}", driver(
        Vec::from([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
      ));
      
      println!("TEST-1...{}", driver(
        Vec::from([-88, -84, -82, -58, -12, 18, 24, 24, 28, 30, 34, 44, 92, 94]), 8, 
        66
      ));
      
      println!("TEST-2...{}", driver(
        Vec::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1]), 15, 
        2
      ));
      
      println!("TEST-3...{}", driver(
        Vec::from([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
      ));
      
      println!("TEST-4...{}", driver(
        Vec::from([-86, -86, -78, -56, -24, -14, -10, -6, 12, 12, 18, 22, 22, 26, 50, 50, 72, 78, 94]), 9, 
        -4
      ));
      
      println!("TEST-5...{}", driver(
        Vec::from([0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1]), 9, 
        2
      ));
      
      println!("TEST-6...{}", driver(
        Vec::from([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
      ));
      
      println!("TEST-7...{}", driver(
        Vec::from([-78, -62, -46, -36, -20, -4, 4, 6, 6, 40, 50, 52, 64, 76, 94]), 13, 
        166
      ));
      
      println!("TEST-8...{}", driver(
        Vec::from([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
      ));
      
      println!("TEST-9...{}", driver(
        Vec::from([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
      ));
      
  }
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 ];
  }