title: Maximum Triplet Sum Array 2
signature: fun maximumTripletSumArray2(arr: ArrayList<Int>, n: Int): Int {
source_py: def maximum_triplet_sum_array_2(arr, n):
      maxA = (- 100000000)
      maxB = (- 100000000)
      maxC = (- 100000000)
      for i in range(0, n):
          if (arr[i] > maxA):
              maxC = maxB
              maxB = maxA
              maxA = arr[i]
          elif (arr[i] > maxB):
              maxC = maxB
              maxB = arr[i]
          elif (arr[i] > maxC):
              maxC = arr[i]
      return ((maxA + maxB) + maxC)
source_cpp: int maximum_triplet_sum_array_2(vector<int> arr, int n) {
    int maxA = INT_MIN, maxB = INT_MIN, maxC = INT_MIN;
    for ( int i = 0;
    i < n;
    i ++ ) {
      if ( arr [ i ] > maxA ) {
        maxC = maxB;
        maxB = maxA;
        maxA = arr [ i ];
      }
      else if ( arr [ i ] > maxB ) {
        maxC = maxB;
        maxB = arr [ i ];
      }
      else if ( arr [ i ] > maxC ) maxC = arr [ i ];
    }
    return ( maxA + maxB + maxC );
  }
question_info.test_list: [{"idx": 0, "outputs": 265, "inputs": {"arr": [4, 7, 12, 21, 22, 25, 27, 28, 28, 31, 32, 32, 41, 45, 47, 51, 53, 60, 61, 61, 63, 71, 74, 82, 83, 85, 88, 92, 96, 96], "n": 28}}, {"idx": 1, "outputs": -100000026, "inputs": {"arr": [-52, 26, 74, -62, -76], "n": 2}}, {"idx": 2, "outputs": 3, "inputs": {"arr": [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 11}}, {"idx": 3, "outputs": 218, "inputs": {"arr": [63, 71, 15, 28, 31, 84, 8, 17, 24, 42, 66, 95, 30], "n": 6}}, {"idx": 4, "outputs": 52, "inputs": {"arr": [-94, -92, -92, -90, -88, -88, -86, -82, -80, -78, -66, -54, -52, -52, -46, -46, -42, -36, -32, -24, -24, -14, -14, -14, -12, -10, 0, 6, 8, 20, 24, 24, 28, 38, 38, 52, 54, 56, 64, 74, 74, 76, 82, 94, 94], "n": 31}}, {"idx": 5, "outputs": 3, "inputs": {"arr": [0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0], "n": 30}}, {"idx": 6, "outputs": -99999966, "inputs": {"arr": [15, 19, 80], "n": 2}}, {"idx": 7, "outputs": 286, "inputs": {"arr": [4, 80, 18, 74, 36, -30, -72, -28, -32, -16, -8, 38, 78, -48, 98, -64, 86, -60, -44, 84, -98, 40, 14, 30, 44, 90, -30, -42, 24, -28, 24, 40, -96, 98, 90, -68, -54, -52, 62, 34, -98, 68, -56, -94, -78, -12, 28], "n": 41}}, {"idx": 8, "outputs": 2, "inputs": {"arr": [0, 1, 1, 1, 1, 1], "n": 3}}, {"idx": 9, "outputs": 292, "inputs": {"arr": [2, 18, 96, 7, 99, 83, 3, 88, 23, 77, 6, 28, 55, 49, 69, 55, 48, 76, 43, 11, 43, 44, 17, 74, 27, 64, 76, 77, 53, 26, 73, 12, 19, 62, 18, 34, 13, 31, 97, 96, 85, 27, 30, 97, 89, 25], "n": 41}}]
question_info.extension: kts
question_info.test_code: package main
  
  import kotlin.text.*
  import kotlin.math.*
  
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  fun validateSolution(actual:Int, expected:Int):Boolean{
    return actual.equals(expected)
  }
  fun driver(arr: ArrayList<Int>, n: Int, expected:Int):String {
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME(arr, n), expected)) {
                return "PASSED"
        }
        return "FAILED"
      } catch (e: Exception){
        return e::class.simpleName as String
      }
  
  }
  
  fun main() {
      var result: String = ""
      result = driver(arrayListOf(4, 7, 12, 21, 22, 25, 27, 28, 28, 31, 32, 32, 41, 45, 47, 51, 53, 60, 61, 61, 63, 71, 74, 82, 83, 85, 88, 92, 96, 96), 28, 265)
      println("TEST-0...${result}")
      
      result = driver(arrayListOf(-52, 26, 74, -62, -76), 2, -100000026)
      println("TEST-1...${result}")
      
      result = driver(arrayListOf(0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), 11, 3)
      println("TEST-2...${result}")
      
      result = driver(arrayListOf(63, 71, 15, 28, 31, 84, 8, 17, 24, 42, 66, 95, 30), 6, 218)
      println("TEST-3...${result}")
      
      result = driver(arrayListOf(-94, -92, -92, -90, -88, -88, -86, -82, -80, -78, -66, -54, -52, -52, -46, -46, -42, -36, -32, -24, -24, -14, -14, -14, -12, -10, 0, 6, 8, 20, 24, 24, 28, 38, 38, 52, 54, 56, 64, 74, 74, 76, 82, 94, 94), 31, 52)
      println("TEST-4...${result}")
      
      result = driver(arrayListOf(0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0), 30, 3)
      println("TEST-5...${result}")
      
      result = driver(arrayListOf(15, 19, 80), 2, -99999966)
      println("TEST-6...${result}")
      
      result = driver(arrayListOf(4, 80, 18, 74, 36, -30, -72, -28, -32, -16, -8, 38, 78, -48, 98, -64, 86, -60, -44, 84, -98, 40, 14, 30, 44, 90, -30, -42, 24, -28, 24, 40, -96, 98, 90, -68, -54, -52, 62, 34, -98, 68, -56, -94, -78, -12, 28), 41, 286)
      println("TEST-7...${result}")
      
      result = driver(arrayListOf(0, 1, 1, 1, 1, 1), 3, 2)
      println("TEST-8...${result}")
      
      result = driver(arrayListOf(2, 18, 96, 7, 99, 83, 3, 88, 23, 77, 6, 28, 55, 49, 69, 55, 48, 76, 43, 11, 43, 44, 17, 74, 27, 64, 76, 77, 53, 26, 73, 12, 19, 62, 18, 34, 13, 31, 97, 96, 85, 27, 30, 97, 89, 25), 41, 292)
      println("TEST-9...${result}")
      
          
  }
  
  main()
question_info.entry_fn_name: maximumTripletSumArray2
question_info.entry_cls_name: Solution
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: kotlinc -script __FILENAME__ -no-reflect -nowarn