title: Find Maximum Product Of A Triplet In Array
signature: fun findMaximumProductOfATripletInArray(arr: ArrayList<Int>, n: Int): Int {
source_py: def find_maximum_product_of_a_triplet_in_array(arr, n):
      if (n < 3):
          return (- 1)
      max_product = (- (sys.maxsize - 1))
      for i in range(0, (n - 2)):
          for j in range((i + 1), (n - 1)):
              for k in range((j + 1), n):
                  max_product = max(max_product, ((arr[i] * arr[j]) * arr[k]))
      return max_product
source_cpp: int find_maximum_product_of_a_triplet_in_array(vector<int> arr, int n) {
    if ( n < 3 ) return - 1;
    int max_product = INT_MIN;
    for ( int i = 0;
    i < n - 2;
    i ++ ) for ( int j = i + 1;
    j < n - 1;
    j ++ ) for ( int k = j + 1;
    k < n;
    k ++ ) max_product = max ( max_product, arr [ i ] * arr [ j ] * arr [ k ] );
    return max_product;
  }
question_info.test_list: [{"idx": 0, "outputs": -1, "inputs": {"arr": [41, 66, 77], "n": 2}}, {"idx": 1, "outputs": 921984, "inputs": {"arr": [92, -34, -36, -50, 20, -94, 2, -86, 22, -50, 74, 84, 52, -84, 98, -50, 88, 26, -36, -36, 6, -50, -48, -84, 38, -96, -62, 34, 52, 92, 40, -84, 18, -90, 54, -38, -74, -98, -8, -92, -60, 86, -36, 94, 56], "n": 40}}, {"idx": 2, "outputs": -1, "inputs": {"arr": [0, 0, 1], "n": 1}}, {"idx": 3, "outputs": 931491, "inputs": {"arr": [2, 77, 99, 95, 78, 15, 69, 39, 34, 43, 66, 45, 97, 27, 67, 62, 64, 2, 28, 94, 41, 87, 97, 52, 14, 61, 78, 50], "n": 26}}, {"idx": 4, "outputs": 69440, "inputs": {"arr": [-62, -28, 40, 76], "n": 3}}, {"idx": 5, "outputs": 1, "inputs": {"arr": [0, 1, 1, 0, 1, 1, 1, 1, 1], "n": 5}}, {"idx": 6, "outputs": 230400, "inputs": {"arr": [2, 6, 10, 11, 12, 12, 17, 18, 18, 19, 20, 22, 24, 25, 30, 35, 36, 37, 40, 41, 42, 47, 60, 60, 64, 69, 69, 70, 73, 79, 80, 83, 97, 97, 97], "n": 25}}, {"idx": 7, "outputs": 740880, "inputs": {"arr": [-72, 98, 68, 18, 92, -84, 50, 32, -90, -40, 50, 60, -50, -50, 50, 24, 30, 94, -98, -6, 46, -46, -24, -62, -20, 62, -76], "n": 14}}, {"idx": 8, "outputs": 0, "inputs": {"arr": [0, 0, 0, 0, 0, 1, 1, 1], "n": 7}}, {"idx": 9, "outputs": 477360, "inputs": {"arr": [85, 36, 7, 69, 9, 45, 18, 47, 1, 78, 72, 53, 37, 20, 95, 71, 58, 41], "n": 14}}]
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(41, 66, 77), 2, -1)
      println("TEST-0...${result}")
      
      result = driver(arrayListOf(92, -34, -36, -50, 20, -94, 2, -86, 22, -50, 74, 84, 52, -84, 98, -50, 88, 26, -36, -36, 6, -50, -48, -84, 38, -96, -62, 34, 52, 92, 40, -84, 18, -90, 54, -38, -74, -98, -8, -92, -60, 86, -36, 94, 56), 40, 921984)
      println("TEST-1...${result}")
      
      result = driver(arrayListOf(0, 0, 1), 1, -1)
      println("TEST-2...${result}")
      
      result = driver(arrayListOf(2, 77, 99, 95, 78, 15, 69, 39, 34, 43, 66, 45, 97, 27, 67, 62, 64, 2, 28, 94, 41, 87, 97, 52, 14, 61, 78, 50), 26, 931491)
      println("TEST-3...${result}")
      
      result = driver(arrayListOf(-62, -28, 40, 76), 3, 69440)
      println("TEST-4...${result}")
      
      result = driver(arrayListOf(0, 1, 1, 0, 1, 1, 1, 1, 1), 5, 1)
      println("TEST-5...${result}")
      
      result = driver(arrayListOf(2, 6, 10, 11, 12, 12, 17, 18, 18, 19, 20, 22, 24, 25, 30, 35, 36, 37, 40, 41, 42, 47, 60, 60, 64, 69, 69, 70, 73, 79, 80, 83, 97, 97, 97), 25, 230400)
      println("TEST-6...${result}")
      
      result = driver(arrayListOf(-72, 98, 68, 18, 92, -84, 50, 32, -90, -40, 50, 60, -50, -50, 50, 24, 30, 94, -98, -6, 46, -46, -24, -62, -20, 62, -76), 14, 740880)
      println("TEST-7...${result}")
      
      result = driver(arrayListOf(0, 0, 0, 0, 0, 1, 1, 1), 7, 0)
      println("TEST-8...${result}")
      
      result = driver(arrayListOf(85, 36, 7, 69, 9, 45, 18, 47, 1, 78, 72, 53, 37, 20, 95, 71, 58, 41), 14, 477360)
      println("TEST-9...${result}")
      
          
  }
  
  main()
question_info.entry_fn_name: findMaximumProductOfATripletInArray
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