Problem 2464 · Medium

Minimum Subarrays in a Valid Split

Prefix DP: the last piece must have endpoints with gcd above one; try each start point and keep the fewest pieces.

Open the interactive visualisation