Problem 442 · Medium

Find All Duplicates in Array

Find every value that appears twice in an array whose values lie between 1 and n, using constant extra space. The visual uses each value as a position marker, flipping signs to show visited positions and collecting the repeats.

Open the interactive visualisation