
You are given an integer array nums. Find the maximum value of the expression:
nums[j] - nums[i] - (j - i)
over all pairs of indices (i, j) such that 0 <= i < j < nums.length.
Explanation: Choosing i = 3 and j = 4 yields nums[4] - nums[3] - (4 - 3) = 18 - 12 - 1 = 5. No other pair produces a larger result.
Explanation: Choosing i = 2 and j = 3 yields nums[3] - nums[2] - (3 - 2) = 8 - 2 - 1 = 5.
Explanation: Choosing i = 0 and j = 1 yields nums[1] - nums[0] - (1 - 0) = 4 - 5 - 1 = -2.
Access the full code editor, ThinkBuddy AI hints, and track your progress.