Math Fundamentals18 sections · 814 units
Open in Course

Problem - Linked List Random Node

Uniform random selection

Given a singly linked list, return a random node's value such that each node has an equal probability of being chosen. You must solve it without knowing the list length in advance.

This introduces reservoir sampling, a technique for selecting a random item from a stream of unknown length with uniform probability.