Problem 1218 · Medium

Longest Arithmetic Subsequence of Given Difference

Find the longest subsequence whose consecutive elements differ by a fixed given step. The visual extends chains while a lookup table keeps the best length ending at each value.

Open the interactive visualisation