1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-02-10 01:10:26 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/划分字母区间 [partition-labels].html

33 lines
1.0 KiB
HTML
Raw Normal View History

2023-12-09 18:42:21 +08:00
<p>给你一个字符串 <code>s</code> 。我们要把这个字符串划分为尽可能多的片段,同一字母最多出现在一个片段中。</p>
2022-03-27 20:46:41 +08:00
2023-12-09 18:42:21 +08:00
<p>注意,划分结果需要满足:将所有划分结果按顺序连接,得到的字符串仍然是 <code>s</code></p>
2022-03-27 20:46:41 +08:00
2023-12-09 18:42:21 +08:00
<p>返回一个表示每个字符串片段的长度的列表。</p>
<p>&nbsp;</p>
<strong class="example">示例 1</strong>
2022-03-27 20:46:41 +08:00
<pre>
2023-12-09 18:42:21 +08:00
<strong>输入:</strong>s = "ababcbacadefegdehijhklij"
2022-03-27 20:46:41 +08:00
<strong>输出:</strong>[9,7,8]
<strong>解释:</strong>
2023-12-09 18:42:21 +08:00
划分结果为 "ababcbaca"、"defegde"、"hijhklij" 。
2022-03-27 20:46:41 +08:00
每个字母最多出现在一个片段中。
2023-12-09 18:42:21 +08:00
像 "ababcbacadefegde", "hijhklij" 这样的划分是错误的,因为划分的片段数较少。 </pre>
<p><strong class="example">示例 2</strong></p>
<pre>
<strong>输入:</strong>s = "eccbbbbdec"
<strong>输出:</strong>[10]
2022-03-27 20:46:41 +08:00
</pre>
2023-12-09 18:42:21 +08:00
<p>&nbsp;</p>
2022-03-27 20:46:41 +08:00
<p><strong>提示:</strong></p>
<ul>
2023-12-09 18:42:21 +08:00
<li><code>1 &lt;= s.length &lt;= 500</code></li>
<li><code>s</code> 仅由小写英文字母组成</li>
2022-03-27 20:46:41 +08:00
</ul>