Max Value of Equation

Revision en1, by Honestly, 2025-06-14 11:12:03

You are given an array points containing the coordinates of points on a 2D plane, sorted by the x-values, where points[i] = [xi, yi] such that xi < xj for all 1 <= i < j <= points.length. You are also given an integer k.

Return the maximum value of the equation yi + yj + |xi — xj| where |xi — xj| <= k and 1 <= i < j <= points.length.

It is guaranteed that there exists at least one pair of points that satisfy the constraint |xi — xj| <= k.

This is the Leetcode problem 1499 ,does anyone have any idea on how to solve this?.i have been scratching my head about this for the last few minutes ,

Tags maximize, constraint

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Honestly 2025-06-14 11:12:03 643 Initial revision (published)