java.lang.Object
g0801_0900.s0830_positions_of_large_groups.Solution

public class Solution extends Object
830 - Positions of Large Groups.<p>Easy</p> <p>In a string <code>s</code> of lowercase letters, these letters form consecutive groups of the same character.</p> <p>For example, a string like <code>s = &quot;abbxxxxzyy&quot;</code> has the groups <code>&quot;a&quot;</code>, <code>&quot;bb&quot;</code>, <code>&quot;xxxx&quot;</code>, <code>&quot;z&quot;</code>, and <code>&quot;yy&quot;</code>.</p> <p>A group is identified by an interval <code>[start, end]</code>, where <code>start</code> and <code>end</code> denote the start and end indices (inclusive) of the group. In the above example, <code>&quot;xxxx&quot;</code> has the interval <code>[3,6]</code>.</p> <p>A group is considered <strong>large</strong> if it has 3 or more characters.</p> <p>Return <em>the intervals of every <strong>large</strong> group sorted in <strong>increasing order by start index</strong></em>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> s = &ldquo;abbxxxxzzy&rdquo;</p> <p><strong>Output:</strong> <a href="3,6">3,6</a></p> <p><strong>Explanation:</strong> <code>&quot;xxxx&quot; is the only</code> large group with start index 3 and end index 6.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> s = &ldquo;abc&rdquo;</p> <p><strong>Output:</strong> []</p> <p><strong>Explanation:</strong> We have groups &ldquo;a&rdquo;, &ldquo;b&rdquo;, and &ldquo;c&rdquo;, none of which are large groups.</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> s = &ldquo;abcdddeeeeaabbbcd&rdquo;</p> <p><strong>Output:</strong> [[3,5],[6,9],[12,14]]</p> <p><strong>Explanation:</strong> The large groups are &ldquo;ddd&rdquo;, &ldquo;eeee&rdquo;, and &ldquo;bbb&rdquo;.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= s.length <= 1000</code></li> <li><code>s</code> contains lowercase English letters only.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details