Reservoir sampling?is a family of?randomized algorithms?for randomly choosing a?sample?of?kitems from a list containing?n?items, where?n?is either a very large or unknown number. Typically?n?is large enough that the list doesn't fit into?main memory.
http://www.geeksforgeeks.org/reservoir-sampling/
比如說題目里等于3的index有2,3瓤帚,4. 所以我們要設計一個1/3的random算法砚偶。