Premium problem163. Interpolate a Curve with Flat Extrapolation

Easy Locked

Given sorted knot positions knot_x and values knot_y, return linearly interpolated values at query_x, holding the first and last knot value flat outside the knot range.

Input

knot_x = [1. 2. 5.]
knot_y = [0.01  0.02  0.035]
query_x = [0.5 1.5 3.  9. ]

Output

[0.01  0.015 0.025 0.035]

Premium problem

This one's part of Premium. Unlock the full NumPy track plus every other premium problem on the site.

Implement solve(...)