diff --git a/leetcode/1913.MaximumProductDifferenceBetweenTwoPairs/maximumProductDifferenceBetweenTwoPairs.go b/leetcode/1913.MaximumProductDifferenceBetweenTwoPairs/maximumProductDifferenceBetweenTwoPairs.go new file mode 100644 index 0000000..a6738da --- /dev/null +++ b/leetcode/1913.MaximumProductDifferenceBetweenTwoPairs/maximumProductDifferenceBetweenTwoPairs.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "sort" +) + +func maxProductDifference(nums []int) int { + sort.Ints(nums) + n := len(nums) + + return (nums[n-1] * nums[n-2]) - (nums[0] * nums[1]) +} + +func main() { + nums := []int{4, 2, 5, 9, 7, 4, 8} + fmt.Println(maxProductDifference(nums)) +}