PHP Max Product Of Three
function maxProductOfThree(array $a): int
{
sort($a);
$c = count($a);
return max($a[$c - 1] * $a[$c - 2] * $a[$c - 3], $a[0] * $a[1] * $a[$c - 1]);
}
This checks the useful extremes, because the best product can come from either the three largest numbers or two negatives plus one large positive.