Quant Memo
Coding/●●●●

Return a random node's value from a linked list you can only read once

You get the head of a singly linked list. It may be enormous, so you cannot store all values or even count them first, and you may walk it only once from head to tail.

Return the value of a uniformly random node, each node with probability 1/n1/n.

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions