abbreviations
to store the initial abbreviations of the words.abbreviations
.prefix
to keep track of the prefix length for each word.abbreviations
, perform the following steps:
a. Create a dictionary groups
to group words by their abbreviations.
b. For each group with more than one word, increment the prefix length for those words in prefix
.
c. Update the abbreviations for the words with increased prefix length.