NewThe Learning module is now liveSee what's new

Given a set of 2D points points where multiple points may have the same x-coordinate, you are to construct a piecewise linear function by using these points. For each query value in a given queries, determine the interpolated y-value according to the following rules:

  • If the query x-value matches a given x-coordinate, use the highest y-value among all points sharing that x.
  • If the query falls strictly between two distinct x-values, interpolate linearly between the highest y-value at the smaller x and the lowest y-value at the larger x.
Test Cases
Input
Output
Expected