Skip to content

Instantly share code, notes, and snippets.

@SilvaAriel
Created February 25, 2021 17:49
Max Pairwise Product Go
func maxPairwiseProduct(numbers []int) float64 {
n := len(numbers)
maxProduct := 0.0
for first, _ := range numbers {
for second := first + 1; second < n; second++ {
maxProduct = math.Max(float64(maxProduct),
float64(numbers[first]*numbers[second]))
}
}
return maxProduct
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment