注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
最近在整理做过的题,求加米!!!
- You are given an unsorted list of points with distinct x-coordinates. Connecting the points in increasing order of x forms a piecewise linear curve. For each query x, return the corresponding y. If x lies outside the input range, extend the nearest end segment. Implement a function that can handle many queries efficiently. For example, use the poinement a streaming version that updates the slope after each new (x,y) pair without retaining the previous observations. Illustrate both versions using the pairs (2,5), (3,7), and (5,12) in that order.
|