Maximize the Product of Pair Distance and Minimum Value
Company: Wayfair
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: hard
Interview Round: Technical Screen
Implement `maximum_pair_score(nums)`. Choose two distinct indices `i` and `j` and maximize:
$$
\min(nums[i], nums[j])\,|i-j|.
$$
Return the maximum score, not the selected pair. Repeated values are allowed. This is the numeric form of the referenced Container With Most Water problem: there are 2 through 100,000 elements, and each integer value is between 0 and 10,000.
### Examples
```text
maximum_pair_score([1,8,6,2,5,4,8,3,7]) -> 49
```
Indices 1 and 8 give a minimum value of 7 and a distance of 7, for a score of 49.
```text
maximum_pair_score([1,1]) -> 1
```
The only distinct pair has distance 1 and minimum value 1. Multiple pairs may share the maximum, but the returned numeric score is unambiguous.
Problem reference: [LeetCode 11](https://leetcode.com/problems/container-with-most-water/).
Overview: Maximize the smaller of two array values times their index distance, using the Container With Most Water objective and returning one deterministic score.
Implement `maximum_pair_score(nums)`. Choose two distinct indices `i` and `j` and maximize:
$$
\min(nums[i], nums[j])\,|i-j|.
$$
Return the maximum score, not the selected pair. Repeated values are allowed. This is the numeric form of the referenced Container With Most Water problem: there are 2 through 100,000 elements, and each integer value is between 0 and 10,000.
### Examples
```text
maximum_pair_score([1,8,6,2,5,4,8,3,7]) -> 49
```
Indices 1 and 8 give a minimum value of 7 and a distance of 7, for a score of 49.
```text
maximum_pair_score([1,1]) -> 1
```
The only distinct pair has distance 1 and minimum value 1. Multiple pairs may share the maximum, but the returned numeric score is unambiguous.
Problem reference: [LeetCode 11](https://leetcode.com/problems/container-with-most-water/).
Constraints
- nums contains 2 through 100000 integers, inclusive.
- Every nums value is between 0 and 10000, inclusive.
- The selected indices must be distinct.
- Return only the maximum numeric score; repeated values and tied maximizing pairs are allowed.
Examples
Input: ([1,8,6,2,5,4,8,3,7],)
Expected Output: 49
Explanation: Source example: indices 1 and 8 have score 7 times 7.
Input: ([1,1],)
Expected Output: 1
Explanation: Source minimum-length example: the single pair scores 1.
Hints
- Only distinct indices may be paired.
- Different maximizing pairs can yield the same returned score.