1858. Longest Word With All Prefixes
Description
**Input:** words = ["k","ki","kir","kira", "kiran"]
**Output:** "kiran"
**Explanation:** "kiran" has prefixes "kira", "kir", "ki", and "k", and all of them appear in words.
**Input:** words = ["a", "banana", "app", "appl", "ap", "apply", "apple"]
**Output:** "apple"
**Explanation:** Both "apple" and "apply" have all their prefixes in words.
However, "apple" is lexicographically smaller, so we return that.
**Input:** words = ["abc", "bc", "ab", "qwe"]
**Output:** ""ac
Last updated