注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
给了三道take home,发过去之后告诉我没有过也没给任何feedback,浪费时间。。。
Problem 1.
Write a Python function that takes numpy array of booleans and returns a numpy array of type int64. The i-th element in the resulting array should contain the distance from the closest true in the input array at or before position i. The resulting array should have a -1 if there is no True value at the current or any previous position. The input array size will be on the100000000. Implementation with python loop over all elements is not considered sufficiently efficient.
Include a unit test that checks relative error of output of your solution for N=20 against an output of a simple solution that accumulates all sums explicitly.
|