830. Positions of Large Groups
题目描述
In a string S of lowercase letters, these letters form consecutive groups of the same character.
For example, a string like S = “abbxxxxzyy” has the groups “a”, “bb”, “xxxx”, “z” and “yy”.
Call a group large if it has 3 or more characters. We would like the starting and ending positions of every large group.
The final answer should be in lexicographic order.
Example 1:
|
|
Example 2:
|
|
Example 3:
|
|
Note: 1 <= S.length <= 1000
题目大意
求字符串内连续重复的字符区间。却连续重复字符数大于等于 3
解题思路
按照题目遍历字符串即可。
代码
|
|