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>If there are multiple such strings, return the<em> </em><strong>lexicographically<em> </em>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>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> a = &quot;abc&quot;, b = &quot;bca&quot;, c = &quot;aaa&quot;
<strong>Output:</strong> &quot;aaabca&quot;
<strong>Explanation:</strong>  We show that &quot;aaabca&quot; 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 &quot;aaabca&quot; is the lexicographically smallest one.</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> a = &quot;ab&quot;, b = &quot;ba&quot;, c = &quot;aba&quot;
<strong>Output:</strong> &quot;aba&quot;
<strong>Explanation: </strong>We show that the string &quot;aba&quot; 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 &quot;aba&quot; is the lexicographically smallest one.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= a.length, b.length, c.length &lt;= 100</code></li>
	<li><code>a</code>, <code>b</code>, <code>c</code> consist only of lowercase English letters.</li>
</ul>

class Solution:
    def minimumString(self, a: str, b: str, c: str) -> str:
        sorted_strings = list(
            sorted(
                [
                    self.helper([a, b, c]),
                    self.helper([a, c, b]),
                    self.helper([b, a, c]),
                    self.helper([b, c, a]),
                    self.helper([c, a, b]),
                    self.helper([c, b, a]),
                ],
                key=lambda x: (len(x), x),
            )
        )
        return sorted_strings[0]

    def helper(self, strings_list):
        max_length = -1
        start_index = -1
        for index in range(len(strings_list[0])):
            if strings_list[0][index] == strings_list[1][0]:
                temp_index = index
                increment = 0
                while (
                    temp_index < len(strings_list[0])
                    and increment < len(strings_list[1])
                    and strings_list[0][temp_index] == strings_list[1][increment]
                ):
                    temp_index += 1
                    increment += 1
                if temp_index - index > max_length and temp_index == len(
                    strings_list[0]
                ):
                    max_length = temp_index - index
                    start_index = index
        if strings_list[0] in strings_list[1]:
            strings_list[0] = ""
        elif max_length >= 0:
            strings_list[0] = strings_list[0][:start_index]
        max_length = -1
        for index in range(len(strings_list[1])):
            if strings_list[1][index] == strings_list[2][0]:
                temp_index = index
                increment = 0
                while (
                    temp_index < len(strings_list[1])
                    and increment < len(strings_list[2])
                    and strings_list[1][temp_index] == strings_list[2][increment]
                ):
                    temp_index += 1
                    increment += 1
                if temp_index - index > max_length and temp_index == len(
                    strings_list[1]
                ):
                    max_length = temp_index - index
        if strings_list[2] in strings_list[1]:
            strings_list[2] = ""
        elif max_length >= 0:
            strings_list[2] = strings_list[2][max_length:]
        return "".join(strings_list)
190