Given n strings each of length <=10^5
.
Input: “aa ab ac ad”
Output: 8
(“a”,”b”,”c”,”d”,”aa”,”ab”,”ac”,”ad”)
Input: “aab bcd”
Output: 10
(“a”,”b”,”c”,”d”,”aa”,”ab”,”bc”,”cd”,”aab”,”bcd”)
update:
suffix tree is one solution.But it takes more memory.
Is there any solution other than suffix tree?