title: Find Maximum Product Of A Triplet In Array 1
signature: fun findMaximumProductOfATripletInArray1(arr: ArrayList<Int>, n: Int): Int {
source_py: def find_maximum_product_of_a_triplet_in_array_1(arr, n):
      if (n < 3):
          return (- 1)
      arr.sort()
      return max(((arr[0] * arr[1]) * arr[(n - 1)]), ((arr[(n - 1)] * arr[(n - 2)]) * arr[(n - 3)]))
source_cpp: int find_maximum_product_of_a_triplet_in_array_1(vector<int> arr, int n) {
    if ( n < 3 ) return - 1;
    sort(arr.begin(), arr.end());
    return max ( arr [ 0 ] * arr [ 1 ] * arr [ n - 1 ], arr [ n - 1 ] * arr [ n - 2 ] * arr [ n - 3 ] );
  }
question_info.test_list: [{"idx": 0, "outputs": 737100, "inputs": {"arr": [5, 8, 14, 15, 18, 21, 21, 21, 27, 29, 30, 33, 34, 34, 35, 37, 40, 41, 44, 44, 46, 49, 54, 58, 60, 61, 61, 63, 66, 69, 69, 70, 81, 82, 82, 90, 90, 90, 91, 92, 92, 96, 97, 99], "n": 39}}, {"idx": 1, "outputs": 268912, "inputs": {"arr": [-98, -98, -90, -88, -76, -66, -60, -58, -56, -52, -50, -32, -32, -22, -2, 12, 18, 28, 32, 48, 50, 56, 68, 70, 70, 72], "n": 18}}, {"idx": 2, "outputs": 1, "inputs": {"arr": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 17}}, {"idx": 3, "outputs": 474012, "inputs": {"arr": [2, 5, 5, 6, 17, 18, 18, 31, 38, 49, 53, 62, 63, 66, 69, 72, 74, 76, 76, 77, 81, 86, 91, 94, 95, 99, 99], "n": 21}}, {"idx": 4, "outputs": 106720, "inputs": {"arr": [-92, -58, -8, 20, 24, 24, 42, 98], "n": 4}}, {"idx": 5, "outputs": 1, "inputs": {"arr": [0, 0, 0, 0, 0, 0, 0, 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, 1], "n": 38}}, {"idx": 6, "outputs": -1, "inputs": {"arr": [46, 64, 81], "n": 1}}, {"idx": 7, "outputs": 529920, "inputs": {"arr": [-96, -92, -80, -40, -26, -18, -14, -8, -4, 4, 20, 34, 34, 42, 44, 58, 60, 68, 76, 92, 94, 96], "n": 17}}, {"idx": 8, "outputs": 1, "inputs": {"arr": [0, 0, 0, 1, 1, 1, 1, 1], "n": 7}}, {"idx": 9, "outputs": 468075, "inputs": {"arr": [1, 1, 4, 6, 17, 17, 18, 23, 28, 41, 46, 52, 58, 61, 70, 73, 75, 79, 79, 83, 94, 97, 98], "n": 19}}]
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(5, 8, 14, 15, 18, 21, 21, 21, 27, 29, 30, 33, 34, 34, 35, 37, 40, 41, 44, 44, 46, 49, 54, 58, 60, 61, 61, 63, 66, 69, 69, 70, 81, 82, 82, 90, 90, 90, 91, 92, 92, 96, 97, 99), 39, 737100)
      println("TEST-0...${result}")
      
      result = driver(arrayListOf(-98, -98, -90, -88, -76, -66, -60, -58, -56, -52, -50, -32, -32, -22, -2, 12, 18, 28, 32, 48, 50, 56, 68, 70, 70, 72), 18, 268912)
      println("TEST-1...${result}")
      
      result = driver(arrayListOf(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), 17, 1)
      println("TEST-2...${result}")
      
      result = driver(arrayListOf(2, 5, 5, 6, 17, 18, 18, 31, 38, 49, 53, 62, 63, 66, 69, 72, 74, 76, 76, 77, 81, 86, 91, 94, 95, 99, 99), 21, 474012)
      println("TEST-3...${result}")
      
      result = driver(arrayListOf(-92, -58, -8, 20, 24, 24, 42, 98), 4, 106720)
      println("TEST-4...${result}")
      
      result = driver(arrayListOf(0, 0, 0, 0, 0, 0, 0, 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, 1), 38, 1)
      println("TEST-5...${result}")
      
      result = driver(arrayListOf(46, 64, 81), 1, -1)
      println("TEST-6...${result}")
      
      result = driver(arrayListOf(-96, -92, -80, -40, -26, -18, -14, -8, -4, 4, 20, 34, 34, 42, 44, 58, 60, 68, 76, 92, 94, 96), 17, 529920)
      println("TEST-7...${result}")
      
      result = driver(arrayListOf(0, 0, 0, 1, 1, 1, 1, 1), 7, 1)
      println("TEST-8...${result}")
      
      result = driver(arrayListOf(1, 1, 4, 6, 17, 17, 18, 23, 28, 41, 46, 52, 58, 61, 70, 73, 75, 79, 79, 83, 94, 97, 98), 19, 468075)
      println("TEST-9...${result}")
      
          
  }
  
  main()
question_info.entry_fn_name: findMaximumProductOfATripletInArray1
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