Tap here to switch tabs
Problem
Submissions

Problem: Longest String Chain

med
30 min
Try to solve the Longest String Chain problem.

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:

  • 11 \leq words.length 103\leq 10^3

  • 11 \leq words[i].length 16\leq 16

  • words[i] consists only of lowercase English letters

Unlock AI-Powered LearningUpgrade to smarter learning with instant explanations of Ask Agent, Personalized Interview Prep, Real-World Projects, 3 AI Mock Interviews per month, and Personalized Paths
Tap here to switch tabs
Problem
Submissions

Problem: Longest String Chain

med
30 min
Try to solve the Longest String Chain problem.

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:

  • 11 \leq words.length 103\leq 10^3

  • 11 \leq words[i].length 16\leq 16

  • words[i] consists only of lowercase English letters

Unlock AI-Powered LearningUpgrade to smarter learning with instant explanations of Ask Agent, Personalized Interview Prep, Real-World Projects, 3 AI Mock Interviews per month, and Personalized Paths