I don't quite follow you. Could you please explain what your len is used for? For example, if we have a, aa, aaa, aaaa, aaab in the trie, what are the values of len at the root node and at root's next node? It would be really helpful if you post your code here :)

the "len" (which means the number of letters that are continuously the same) can help us to leap several letters forward instead of one letter per time.

However, the "len" may not be the maximum leap.

For example, abbbc and abbcd in a trie is:

a(len=1)b(len=2)b(len=1)c(len=1)a(len=1)b(len=2)c(len=1)d(len=1)We can only leap 2 letters at b instead of 3 letters

And there could be worse case if we put abcde into the trie, the trie will become: a(len=1)b(len=1)b(len=1)b(len=1)c(len=1)a(len=1)b(len=1)b(len=1)c(len=1)d(len=1)a(len=1)b(len=1)c(len=1)d(len=1)e(len=1)

So, its worst case will be just like a normal trie(require extra space to store "len").

in your case, we will construct 4 trie (first categorized by length of string)