Google | Longest Word in Dictionary 2
3092

In this problem we will extend Longest Word in Dictionary by allowing insertion of a new character in any position not only at the end. Return the construction path of the longest word.

Example 1:

Input: words = ["o", "or", "ord", "word", "world"]
Output: ["o", "or", "ord", "word", "world"]

Example 2:

Input: ["o", "or", "ord", "word", "world", "p", "ap", "ape", "appe", "apple", "apples"]
Output: ["p", "ap", "ape", "appe", "apple", "apples"]
Comments (11)