Class Solution
java.lang.Object
g2401_2500.s2405_optimal_partition_of_string.Solution
2405 - Optimal Partition of String.<p>Medium</p>
<p>Given a string <code>s</code>, partition the string into one or more <strong>substrings</strong> such that the characters in each substring are <strong>unique</strong>. That is, no letter appears in a single substring more than <strong>once</strong>.</p>
<p>Return <em>the <strong>minimum</strong> number of substrings in such a partition.</em></p>
<p>Note that each character should belong to exactly one substring in a partition.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> s = “abacaba”</p>
<p><strong>Output:</strong> 4</p>
<p><strong>Explanation:</strong></p>
<p>Two possible partitions are (“a”,“ba”,“cab”,“a”) and (“ab”,“a”,“ca”,“ba”).</p>
<p>It can be shown that 4 is the minimum number of substrings needed.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> s = “ssssss”</p>
<p><strong>Output:</strong> 6</p>
<p><strong>Explanation:</strong></p>
<p>The only valid partition is (“s”,“s”,“s”,“s”,“s”,“s”).</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= s.length <= 10<sup>5</sup></code></li>
<li><code>s</code> consists of only English lowercase letters.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
partitionString
-