Problem 1998 · Hard

GCD Sort of an Array

Decide whether values can be sorted when swaps are allowed between values sharing a common factor above one. The visual links values to their prime factors with union-find.

Open the interactive visualisation