Problems > GCD of Everything > Editorial

GCD of Everything — Solution & Editorial

Back to the Problem

Fold the Euclidean gcd across the array; it only shrinks, and gcd(0, x) = x starts the fold cleanly.

Complexity: O(N log max)