classSolution { publicintfindMaxValueOfEquation(int[][] points, int k) { intans= Integer.MIN_VALUE; // (xi, yi - xi) Deque<int[]> q = newArrayDeque<>(); for (int[] point : points) { intx= point[0], y = point[1]; while (!q.isEmpty() && q.peekFirst()[0] < x - k) q.pollFirst(); if (!q.isEmpty()) { ans = Math.max(ans, x + y + q.peekFirst()[1]); } while (!q.isEmpty() && q.peekLast()[1] <= y - x) q.pollLast(); q.offerLast(newint[]{x, y - x}); } return ans; } }