Class Solution
java.lang.Object
g0801_0900.s0820_short_encoding_of_words.Solution
820 - Short Encoding of Words.<p>Medium</p>
<p>A <strong>valid encoding</strong> of an array of <code>words</code> is any reference string <code>s</code> and array of indices <code>indices</code> such that:</p>
<ul>
<li><code>words.length == indices.length</code></li>
<li>The reference string <code>s</code> ends with the <code>'#'</code> character.</li>
<li>For each index <code>indices[i]</code>, the <strong>substring</strong> of <code>s</code> starting from <code>indices[i]</code> and up to (but not including) the next <code>'#'</code> character is equal to <code>words[i]</code>.</li>
</ul>
<p>Given an array of <code>words</code>, return <em>the <strong>length of the shortest reference string</strong></em> <code>s</code> <em>possible of any <strong>valid encoding</strong> of</em> <code>words</code><em>.</em></p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> words = [“time”, “me”, “bell”]</p>
<p><strong>Output:</strong> 10</p>
<p><strong>Explanation:</strong> A valid encoding would be s = <code>"time#bell#" and indices = [0, 2, 5</code>].</p>
<p>words[0] = “time”, the substring of s starting from indices[0] = 0 to the next ‘#’ is underlined in “time#bell#”</p>
<p>words[1] = “me”, the substring of s starting from indices[1] = 2 to the next ‘#’ is underlined in “time#bell#”</p>
<p>words[2] = “bell”, the substring of s starting from indices[2] = 5 to the next ‘#’ is underlined in “time#bell#”</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> words = [“t”]</p>
<p><strong>Output:</strong> 2</p>
<p><strong>Explanation:</strong> A valid encoding would be s = “t#” and indices = [0].</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= words.length <= 2000</code></li>
<li><code>1 <= words[i].length <= 7</code></li>
<li><code>words[i]</code> consists of only lowercase letters.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
minimumLengthEncoding
-