java.lang.Object
g1501_1600.s1593_split_a_string_into_the_max_number_of_unique_substrings.Solution

public class Solution extends Object
1593 - Split a String Into the Max Number of Unique Substrings.<p>Medium</p> <p>Given a string <code>s</code>, return <em>the maximum number of unique substrings that the given string can be split into</em>.</p> <p>You can split string <code>s</code> into any list of <strong>non-empty substrings</strong> , where the concatenation of the substrings forms the original string. However, you must split the substrings such that all of them are <strong>unique</strong>.</p> <p>A <strong>substring</strong> is a contiguous sequence of characters within a string.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> s = &ldquo;ababccc&rdquo;</p> <p><strong>Output:</strong> 5</p> <p><strong>Explanation:</strong> One way to split maximally is [&lsquo;a&rsquo;, &lsquo;b&rsquo;, &lsquo;ab&rsquo;, &lsquo;c&rsquo;, &lsquo;cc&rsquo;]. Splitting like [&lsquo;a&rsquo;, &lsquo;b&rsquo;, &lsquo;a&rsquo;, &lsquo;b&rsquo;, &lsquo;c&rsquo;, &lsquo;cc&rsquo;] is not valid as you have &lsquo;a&rsquo; and &lsquo;b&rsquo; multiple times.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> s = &ldquo;aba&rdquo;</p> <p><strong>Output:</strong> 2</p> <p><strong>Explanation:</strong> One way to split maximally is [&lsquo;a&rsquo;, &lsquo;ba&rsquo;].</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> s = &ldquo;aa&rdquo;</p> <p><strong>Output:</strong> 1</p> <p><strong>Explanation:</strong> It is impossible to split the string any further.</p> <p><strong>Constraints:</strong></p> <ul> <li> <p><code>1 <= s.length <= 16</code></p> </li> <li> <p><code>s</code> contains only lower case English letters.</p> </li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • maxUniqueSplit

      public int maxUniqueSplit(String s)