Problem 2370 · Medium

Longest Ideal Subsequence

Track the longest chain ending in each letter, and extend it from letters within k of the next one.

Open the interactive visualisation