1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/较大分组的位置 [positions-of-large-groups].html
2022-03-29 12:43:11 +08:00

50 lines
1.7 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>在一个由小写字母构成的字符串 <code>s</code> 中,包含由一些连续的相同字符所构成的分组。</p>
<p>例如,在字符串 <code>s = "abbxxxxzyy"</code> 中,就含有 <code>"a"</code>, <code>"bb"</code>, <code>"xxxx"</code>, <code>"z"</code><code>"yy"</code> 这样的一些分组。</p>
<p>分组可以用区间 <code>[start, end]</code> 表示,其中 <code>start</code><code>end</code> 分别表示该分组的起始和终止位置的下标。上例中的 <code>"xxxx"</code> 分组用区间表示为 <code>[3,6]</code></p>
<p>我们称所有包含大于或等于三个连续字符的分组为 <strong>较大分组</strong></p>
<p>找到每一个 <strong>较大分组</strong> 的区间,<strong>按起始位置下标递增顺序排序后</strong>,返回结果。</p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>s = "abbxxxxzzy"
<strong>输出:</strong>[[3,6]]
<strong>解释</strong><strong></strong><code>"xxxx" 是一个起始于 3 且终止于 6 的较大分组</code>
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>s = "abc"
<strong>输出:</strong>[]
<strong>解释:</strong>"a","b" 和 "c" 均不是符合要求的较大分组。
</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>s = "abcdddeeeeaabbbcd"
<strong>输出:</strong>[[3,5],[6,9],[12,14]]
<strong>解释:</strong>较大分组为 "ddd", "eeee" 和 "bbb"</pre>
<p><strong>示例 4</strong></p>
<pre>
<strong>输入:</strong>s = "aba"
<strong>输出:</strong>[]
</pre>
 
<p><strong>提示:</strong></p>
<ul>
<li><code>1 <= s.length <= 1000</code></li>
<li><code>s</code> 仅含小写英文字母</li>
</ul>