https://en.wikipedia.org/wiki/Reservoir_sampling 随机算法,维基解释得很到位。 例题:leetcode 382. Linked List Random Node 这也是第一篇博客,以后有时间就自己写写东西吧