title: Find Maximum Product Of A Triplet In Array
signature: function find_maximum_product_of_a_triplet_in_array(arr, n)
test_code: 
  
  -- SOLUTION CODE
  -- ============================================
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  function isCorrect(actual, expected)
      if type(expected) ~= type(actual) then
          return false
      end
      
      if type(expected) == 'table' then
          for k,v_expected in pairs(expected) do
              
              if actual[k] == nil then
                  return false
              end
              local v_actual = actual[k]
              if not isCorrect(v_actual, v_expected) then
                  return false
              end
              actual[k]=nil
          end
      
          if next(actual) then 
              return false
          end
          return true
      else
          return actual == expected
      end
  end
  
  function validateSolution(actual, expected)
      return isCorrect(actual,expected)
  end
  
  function driver(arr, n, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(arr, n) 
      end)
      if status then
          if validateSolution(exec_result,expected) then
              return "PASSED"
          end
          return "FAILED"
      else
          return string.format("ERROR=%s",string.gsub(error_msg,".*:[%d]+: ",""))
      end
  end
      
  function main()
      result = driver({41, 66, 77}, 2, -1)
      print(string.format("TEST-0...%s",result))
  
      result = driver({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)
      print(string.format("TEST-1...%s",result))
  
      result = driver({0, 0, 1}, 1, -1)
      print(string.format("TEST-2...%s",result))
  
      result = driver({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)
      print(string.format("TEST-3...%s",result))
  
      result = driver({-62, -28, 40, 76}, 3, 69440)
      print(string.format("TEST-4...%s",result))
  
      result = driver({0, 1, 1, 0, 1, 1, 1, 1, 1}, 5, 1)
      print(string.format("TEST-5...%s",result))
  
      result = driver({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)
      print(string.format("TEST-6...%s",result))
  
      result = driver({-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)
      print(string.format("TEST-7...%s",result))
  
      result = driver({0, 0, 0, 0, 0, 1, 1, 1}, 7, 0)
      print(string.format("TEST-8...%s",result))
  
      result = driver({85, 36, 7, 69, 9, 45, 18, 47, 1, 78, 72, 53, 37, 20, 95, 71, 58, 41}, 14, 477360)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
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;
  }