Skip to content
RED SAGSkills
hard20 pts · first answer countsmathprobabilityalgorithms

Picking one random log line from a stream

You read an unknown number of log lines and must keep one chosen uniformly at random, using O(1) memory. With what chance should line i (counting from 1) replace the kept line?

Choose one answer

Discussion 0

Join free to post in the discussion.

Related questions