Back to problems

Interpolate Y-Value for Given X-Value

Algorithm · Tradedesk · Easy

Write a function that estimates a y-value for any given x, using a set of known (x, y) pairs. The x-values are guaranteed to be strictly increasing. Your job is to perform linear interpolation when the target x falls between two known points. If the target x lies outside the known range, you may decide the behavior: raise a ValueError, return the y-value of the nearest endpoint, or perform linear extrapolation. Function Signature Input array_x: A list of floats, sorted in…

Checking your access…