Sunday, October 22, 2017

[LeetCode]Random Pick Index


不让我们用太多空间,我们用时间换空间即可。O(N)时间用Reservoir Sampling生成随机数,常数空间,代码如下:


No comments:

Post a Comment