Go Max Product Of Three
func maxProductOfThree(a []int) int {
sorted := append([]int(nil), a...)
sort.Ints(sorted)
c := len(sorted)
return max(sorted[c-1]*sorted[c-2]*sorted[c-3], sorted[0]*sorted[1]*sorted[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.