Put every word in a trie, then depth-first-search from the start of the trie, only searching nodes that ended a word. Every node found (except the root, which is a specialcase) then represents a word with all it's prefixes present. We take the best such word.https://leetcode.com/...
Put every word in a trie, then depth-first-search from the start of the trie, only searching nodes that ended a word. Every node found (except the root, which is a specialcase) then represents a word with all it's prefixes present. We take the best such word.https://leetcode.com/...