Python Max Product Of Three
def max_product_of_three(a: list[int]) -> int:
a = sorted(a)
c = len(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.