2042. Maximum Product Difference Between Two Pairs
My accepted Python solution to LeetCode problem 2042, Maximum Product Difference Between Two Pairs, running in 140ms.
- Difficulty: Easy
- Python
- Runtime 140ms
- Memory 18.9MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 140ms, memory 18.9MB, accepted 2025-12-31.
class Solution:
def maxProductDifference(self, nums: List[int]) -> int:
nums.sort()
return nums[-1] * nums[-2] - nums[0] * nums[1]