Shortest Encoding
Solve a medium-level problem of generating the shortest encoding from multiple strings using tries.
Problem statement
Given an array of strings, encode the given strings into a single reference string and an array of integers called indexes, such that the size of the word array is the same as the index array. Furthermore, for every word of the input, the reference string ends with a #
character, and for each index indices[i]
, the substring of indices[i]
and up to the next #
character is equal to words[i]
. Based on these conditions, return the length of the shortest reference string.
Example
Sample input
Get hands-on with 1400+ tech skills courses.