Max Value of Equation
Given an array of points sorted by x-coordinate and an integer k, find the maximum value of the equation yi + yj + |xi - xj| where |xi - xj| <= k and i < j.
Max Value of Equation

Given an array of points sorted by x-coordinate and an integer k, find the maximum value of the equation yi + yj + |xi - xj| where |xi - xj| <= k and i < j.

Example 1:
Input: {"points":[[1,3],[2,0],[5,10],[6,-10]],"k":1}
Output: 4
Input
arr ={"points":[[1,3],[2,0],[5,10],[6,-10]],"k":1}

Points: [[1,3], [2,0], [5,10], [6,-10]], k=1

Points on Coordinate Plane (k=1)

(1,3)(2,0)(5,10)(6,-10)

Monotonic Deque (yi - xi, xi)

empty

Max Value:

-∞

Variables
No variables to display
DepthFunction Call
Stack empty
0/5