pyassistant

Longest Deletion Word Chain

Given a list of words (strings), a word B is a direct successor of word A if B can be formed by deleting exactly one character from A without reordering the remaining characters. A word chain is a sequence of words [w1, w2, ..., wk] such that w{i+1} is a direct successor of w{i}. Return the length of the longest possible word chain that can be formed from the given list. Each word from the input list may be used multiple times in different chains but each element in a specific chain must come from the input list (duplicates in input are allowed and treated as distinct entries if they are equal strings).

Example:

Input:
['a', 'b', 'ba', 'bca', 'bda', 'bdca']
Output:
4

Make sure you return your solution, don't print!

AI

Bot

Trying to solve my challenge? Ask if you must, or press the purple button so I can analyze your code.