- See Code
O(n K^2)
class Solution:
def minimumLengthEncoding(self, words: List[str]) -> int:
s = set(words)
for w in words:
for i in range(1, len(w)):
s.discard(w[i:])
return len(s) + sum([len(w) for w in s])