Tap here to switch tabs
Problem
Submissions

Problem: Maximum Product Difference Between Two Pairs

Maximum Product Difference Between Two Pairs asks you to choose four distinct elements from an array, divide them into two pairs, and return the largest possible difference, defined as one pair's product minus the other's.

Statement

Given an integer array nums, choose 44 distinct indices w, x, y, and z such that the product difference between pair (nums[w], nums[x]) and pair (nums[y], nums[z]) is maximized.

The product difference between two pairs (a,b)(a, b) and (c,d)(c, d) is defined as (a⋅b)−(c⋅d)(a \cdot b) - (c \cdot d).

Return the maximum possible product difference.

Constraints:

  • 4≤4 \leq nums.length ≤104\leq 10^4

  • 1≤1 \leq nums[i] ≤104\leq 10^4

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Product Difference Between Two Pairs

Maximum Product Difference Between Two Pairs asks you to choose four distinct elements from an array, divide them into two pairs, and return the largest possible difference, defined as one pair's product minus the other's.

Statement

Given an integer array nums, choose 44 distinct indices w, x, y, and z such that the product difference between pair (nums[w], nums[x]) and pair (nums[y], nums[z]) is maximized.

The product difference between two pairs (a,b)(a, b) and (c,d)(c, d) is defined as (a⋅b)−(c⋅d)(a \cdot b) - (c \cdot d).

Return the maximum possible product difference.

Constraints:

  • 4≤4 \leq nums.length ≤104\leq 10^4

  • 1≤1 \leq nums[i] ≤104\leq 10^4