Problem 2807 · Medium

Insert Greatest Common Divisors in Linked List

Walk neighbouring nodes once and splice the gcd of each pair between them.

Open the interactive visualisation