Skip to content

Practice Positions of Large Groups

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#830
LeetCode Problem

Positions of Large Groups

Problem Statement

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". A group is identified by an interval [start, end], where start and end denote the start and end indices (inclusive) of the group. In the above example, "xxxx" has the interval [3,6]. A group is considered large if it has 3 or more characters. Return the intervals of every large group sorted in increasing order by start index.

Source: Positions of Large Groups on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "abbxxxxzzy"
Output
[[3,6]]

# Example 2

Input
s = "abc"
Output
[]

# Example 3

Input
s = "abcdddeeeeaabbbcd"
Output
[[3,5],[6,9],[12,14]]

Constraints

1 <= s.length <= 1000
s contains lowercase English letters only.

Related LeetCode Problems

Practice more problems similar to Positions of Large Groups.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.