title: Find Maximum Product Of A Triplet In Array 1
signature: func findMaximumProductOfATripletInArray1(arr []int, n int) int {
test_code: package main
  
  import (
      "fmt"
      "reflect"
      "math"
      "sort"
  )
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  func validateSolution(actual int, expected int) bool {
      return reflect.DeepEqual(actual,expected)
  }
  
  func driver(arr []int, n int, expected int) string {
      if validateSolution(PLACEHOLDER_FN_NAME(arr, n),expected) {
              return "PASSED"
      }
      return "FAILED"
  
  }
  
  func main() {
  
      // Use imports to avoid undefined errors
      var _ = reflect.DeepEqual
      _ = math.Abs
      _ = sort.Sort
      result := ""
      result = driver([]int{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)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver([]int{-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)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver([]int{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)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver([]int{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)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver([]int{-92, -58, -8, 20, 24, 24, 42, 98}, 
  	4, 106720)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver([]int{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)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver([]int{46, 64, 81}, 
  	1, -1)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver([]int{-96, -92, -80, -40, -26, -18, -14, -8, -4, 4, 20, 34, 34, 42, 44, 58, 60, 68, 76, 92, 94, 96}, 
  	17, 529920)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver([]int{0, 0, 0, 1, 1, 1, 1, 1}, 
  	7, 1)
      fmt.Printf("TEST-8...%s\n", result)
      
      result = driver([]int{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)
      fmt.Printf("TEST-9...%s\n", result)
      
          
  }
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 ] );
  }