Class Solution
java.lang.Object
g2701_2800.s2800_shortest_string_that_contains_three_strings.Solution
2800 - Shortest String That Contains Three Strings.<p>Medium</p>
<p>Given three strings <code>a</code>, <code>b</code>, and <code>c</code>, your task is to find a string that has the <strong>minimum</strong> length and contains all three strings as <strong>substrings</strong>.</p>
<p>If there are multiple such strings, return the <strong>lexicographically smallest</strong> one.</p>
<p>Return <em>a string denoting the answer to the problem.</em></p>
<p><strong>Notes</strong></p>
<ul>
<li>A string <code>a</code> is <strong>lexicographically smaller</strong> than a string <code>b</code> (of the same length) if in the first position where <code>a</code> and <code>b</code> differ, string <code>a</code> has a letter that appears <strong>earlier</strong> in the alphabet than the corresponding letter in <code>b</code>.</li>
<li>A <strong>substring</strong> is a contiguous sequence of characters within a string.</li>
</ul>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> a = “abc”, b = “bca”, c = “aaa”</p>
<p><strong>Output:</strong> “aaabca”</p>
<p><strong>Explanation:</strong> We show that “aaabca” contains all the given strings: a = ans[2…4], b = ans[3..5], c = ans[0..2]. It can be shown that the length of the resulting string would be at least 6 and “aaabca” is the lexicographically smallest one.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> a = “ab”, b = “ba”, c = “aba”</p>
<p><strong>Output:</strong> “aba”</p>
<p><strong>Explanation:</strong> We show that the string “aba” contains all the given strings: a = ans[0..1], b = ans[1..2], c = ans[0..2]. Since the length of c is 3, the length of the resulting string would be at least 3. It can be shown that “aba” is the lexicographically smallest one.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= a.length, b.length, c.length <= 100</code></li>
<li><code>a</code>, <code>b</code>, <code>c</code> consist only of lowercase English letters.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
minimumString
-