Skip to content

Instantly share code, notes, and snippets.

@adicuco
Created June 16, 2018 16:01
Show Gist options
  • Select an option

  • Save adicuco/2a864bce8a4e4bf5d035951106dcc3d7 to your computer and use it in GitHub Desktop.

Select an option

Save adicuco/2a864bce8a4e4bf5d035951106dcc3d7 to your computer and use it in GitHub Desktop.
100% solution for Maximum Product of Three Task on Codility
function solution(A) {
A.sort(function(a, b) {
return a - b;
});
var max1 = A[A.length - 1] * A[A.length - 2] * A[A.length - 3];
var max2 = A[A.length - 1] * A[0] * A[1];
return max1 > max2 ? max1 : max2;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment