One minute
Leetcode 1913
1913. Maximum Product Difference Between Two Pairs
For this solution, we have to get the maximum Product Difference and to do this, we have to subtract the smallest product from the largest product. So in this solution, I decided to sort nums
and return the max product minus the min product.
func maxProductDifference(nums []int) int {
sort.Ints(nums)
return nums[len(nums) - 1] * nums[len(nums) - 2] - nums[0] * nums[1]
}
Read other posts