Algorithm · Wayfair · Hard
Write a function maximum_pair_score(nums) that takes an array of nonnegative integers. For any two distinct indices i and j, define the pair score as: $$ \min(nums[i], nums[j]) \times i - j $$ Return the largest possible score over all pairs with i != j. You only need to return the maximum numeric score, not the chosen indices. The array may contain duplicate values. Example 1: Explanation: Choosing indices 0 and 4 gives min(3, 5) * 4 = 12, which is the largest possible…
Checking your access…