Search⌘ K
AI Features

Solution: Longest String Chain

Let's solve the Longest String Chain problem using the Dynamic Programming pattern.

Statement

Given an array words, where each word consists of lowercase English letters, a word word_A is considered a predecessor of word_B if and only if exactly one letter can be inserted anywhere into word_A (without reordering the remaining characters) to produce word_B.

A word chain is a sequence [word_1, word_2, ..., word_k] where k1k \geq 1, and each word is a predecessor of the next. A single word trivially forms a word chain of length 11.

Return the length of the longest possible word chain using words chosen from the given words array.

Constraints:

  • 1 ...