Given a list of words, return the length of the shortest reference string that encodes all words as suffixes separated by '#'. Pattern focus: Trie Node Structure. Reverse-word trie construction is useful for removing suffix-covered words before counting the final encoding length.
words = array of lowercase words
minimum encoding length
Example 1:
Input:
words = ["time","me","bell"]
Output:
10
Explanation:
Only the words that are not suffixes of another word contribute to the final encoding.
Example 2:
Input:
words = ["t"]
Output:
2
Explanation:
A single word still needs the trailing separator character.
Example 3:
Input:
words = ["time","time","me"]
Output:
5
Explanation:
Duplicate words are ignored, and suffix-covered words are removed from the count.