Longest String Chain

Medium · Dynamic Programming · about 20 minutes

Asked at Google, Amazon, Meta, Microsoft.

Word a is a predecessor of b if inserting exactly one letter anywhere in a gives b. A word chain is a sequence where each word is a predecessor of the next. Return the length of the longest chain you can build from words.

Related guides