A telecommunications device emits continuously emits numbers. Ideally, whenever a particular number is emitted, it should later be emitted again. Numbers can be repeatedly emitted, but, in the end, they should be emitted an even number of times.
Given a stream of the devices' output numbers, design an algorithm to test whether the above constraint is satisfied.