830. Positions of Large Groups Easy
1/**
2 * [830] Positions of Large Groups
3 *
4 * In a string <font face="monospace">s</font> of lowercase letters, these letters form consecutive groups of the same character.
5 * For example, a string like s = "abbxxxxzyy" has the groups "a", "bb", "xxxx", "z", and "yy".
6 * 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].
7 * A group is considered large if it has 3 or more characters.
8 * Return the intervals of every large group sorted in increasing order by start index.
9 *
10 * Example 1:
11 *
12 * Input: s = "abbxxxxzzy"
13 * Output: [[3,6]]
14 * Explanation: "xxxx" is the only large group with start index 3 and end index 6.
15 *
16 * Example 2:
17 *
18 * Input: s = "abc"
19 * Output: []
20 * Explanation: We have groups "a", "b", and "c", none of which are large groups.
21 *
22 * Example 3:
23 *
24 * Input: s = "abcdddeeeeaabbbcd"
25 * Output: [[3,5],[6,9],[12,14]]
26 * Explanation: The large groups are "ddd", "eeee", and "bbb".
27 *
28 *
29 * Constraints:
30 *
31 * 1 <= s.length <= 1000
32 * s contains lowercase English letters only.
33 *
34 */
35pub struct Solution {}
36
37// problem: https://leetcode.com/problems/positions-of-large-groups/
38// discuss: https://leetcode.com/problems/positions-of-large-groups/discuss/?currentPage=1&orderBy=most_votes&query=
39
40// submission codes start here
41
42impl Solution {
43 pub fn large_group_positions(s: String) -> Vec<Vec<i32>> {
44 vec![]
45 }
46}
47
48// submission codes end
49
50#[cfg(test)]
51mod tests {
52 use super::*;
53
54 #[test]
55 fn test_830() {
56 }
57}
58
Back
© 2025 bowen.ge All Rights Reserved.