← Amazon questions

Select K random numbers from a stream

Filed under Amazon

Given a stream of items of large and unknown length, design an algorithm to randomly select K items such that each item has an equal probability of 1/N of being chosen.

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related Amazon questions

Collected from public candidate posts and coding forums. Updated Nov 2026.