Skip to content

Practice Maximum Product Difference Between Two Pairs

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#1913
LeetCode Problem

Maximum Product Difference Between Two Pairs

Problem Statement

The product difference between two pairs (a, b) and (c, d) is defined as (a * b) - (c * d). Given an integer array nums, choose four distinct indices w, x, y, and z such that the product difference between pairs (nums[w], nums[x]) and (nums[y], nums[z]) is maximized. Return the maximum such product difference.

Source: Maximum Product Difference Between Two Pairs on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [5,6,2,7,4]
Output
34

# Example 2

Input
nums = [4,2,5,9,7,4,8]
Output
64

Constraints

4 <= nums.length <= 10^4
1 <= nums[i] <= 10^4

Related LeetCode Problems

Practice more problems similar to Maximum Product Difference Between Two Pairs.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.