2
def findMaxValueOfEquation(self, points: List[List[int]], k: int) -> int:4
Eqn is: yi + yj + |xi - xj|5
Since points is sorted by x values,6
therefore, xj will always be greater than xi7
therefore xi - xj will always be negative8
So the above eqn can be rewritten as,10
Now the problem boils down to finding maximum in sliding window of k size.11
(https://leetcode.com/problems/sliding-window-maximum/discuss/1911533/Python-or-Dequeue-or-Sliding-Window-or-Simple-Solution)16
while queue and abs(queue[0][0] - x) > k:20
maxVal = max(maxVal, y + x + queue[0][1])22
while queue and queue[-1][1] <= y - x:25
queue.append((x, y - x))