0820. Short Encoding of Words
https://leetcode.com/problems/short-encoding-of-words
Description
A valid encoding of an array of words
is any reference string s
and array of indices indices
such that:
words.length == indices.length
The reference string
s
ends with the'#'
character.For each index
indices[i]
, the substring ofs
starting fromindices[i]
and up to (but not including) the next'#'
character is equal towords[i]
.
Given an array of words
, return the length of the shortest reference string s
possible of any valid encoding of words
.
Example 1:
Example 2:
Constraints:
1 <= words.length <= 2000
1 <= words[i].length <= 7
words[i]
consists of only lowercase letters.
ac
Last updated