mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-04 23:11:41 +08:00
国外版
This commit is contained in:
32
算法题(国外版)/partition-labels.html
Normal file
32
算法题(国外版)/partition-labels.html
Normal file
@@ -0,0 +1,32 @@
|
||||
<p>You are given a string <code>s</code>. We want to partition the string into as many parts as possible so that each letter appears in at most one part.</p>
|
||||
|
||||
<p>Note that the partition is done so that after concatenating all the parts in order, the resultant string should be <code>s</code>.</p>
|
||||
|
||||
<p>Return <em>a list of integers representing the size of these parts</em>.</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> s = "ababcbacadefegdehijhklij"
|
||||
<strong>Output:</strong> [9,7,8]
|
||||
<strong>Explanation:</strong>
|
||||
The partition is "ababcbaca", "defegde", "hijhklij".
|
||||
This is a partition so that each letter appears in at most one part.
|
||||
A partition like "ababcbacadefegde", "hijhklij" is incorrect, because it splits s into less parts.
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> s = "eccbbbbdec"
|
||||
<strong>Output:</strong> [10]
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= s.length <= 500</code></li>
|
||||
<li><code>s</code> consists of lowercase English letters.</li>
|
||||
</ul>
|
Reference in New Issue
Block a user