Short Encoding of Words
mediumMinimize encoded length by merging shared suffixes in a trie
Short Encoding of Words
Key Insight
A word that is a suffix of another adds no new nodes in reversed trie, so it contributes 0 length.
Step 1Insert Reversed Words
Array
time
0me
1bell
2HashMap
time:4
me:2
bell:4
time, me, bell become reversed words for suffix checking.
1 / 3