// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
let left, right, triplet;
A.sort((a, b) => a - b);
N = A.length;
if(A[N-1] <= 0) {
triplet = A[N-3] * A[N-2] * A[N-1];
}else {
left = A[0] * A[1] * A[N-1];
right = A[N-3] * A[N-2] * A[N-1];
if(left > right) {
triplet = left;
}else {
triplet = right;
}
}
return triplet;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
A.sort((a, b) => b - a)
return A.slice(0, 3).reduce((a, b) => {return a * b}, 1)
}
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# write your code in Python 3.6
A.sort()
return max(A[0] * A[1] * A[-1], A[-3] * A[-2] * A[-1])