package leetcode;

import java.util.List;

/**
 * https://leetcode.com/problems/positions-of-large-groups/
 */
public class Problem830 {
    public List<List<Integer>> largeGroupPositions(String S) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem830 prob = new Problem830();
        System.out.println(prob.largeGroupPositions("abbxxxxzzy")); // [[3,6]]
        System.out.println(prob.largeGroupPositions("abc")); // []
        System.out.println(prob.largeGroupPositions("abcdddeeeeaabbbcd")); // [[3,5],[6,9],[12,14]]
    }
}

@@ -12,16 +12,69 @@
 tcode;%0A%0A
+import java.util.ArrayList;%0Aimport java.util.Arrays;%0A
 import j
@@ -88,16 +88,16 @@
 l.List;%0A
-
 %0A/**%0A * 
@@ -258,378 +258,717 @@
     
-// TODO%0A        return null
+List%3CList%3CInteger%3E%3E result = new ArrayList%3C%3E();%0A        int count = 0
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem830 prob = new Problem830();%0A        System.out.println(prob.largeGroupPositions(%22abbxxxxzzy%22)); // %5B%5B3,6%5D%5D%0A        System.out.println(prob.largeGroupPositions(%22abc%22)); // %5B%5D%0A        System.out.println(prob.largeGroupPositions(%22abcdddeeeeaabbbcd%22)); // %5B%5B3,5%5D,%5B6,9%5D,%5B12,14%5D%5D
+int prevIdx = 0;%0A        for (int i = 0; i %3C S.length(); i++) %7B%0A            if (i == 0) %7B%0A                prevIdx = 0;%0A                count++;%0A            %7D else %7B%0A                if (S.charAt(prevIdx) == S.charAt(i)) %7B%0A                    count++;%0A                %7D else %7B%0A                    if (count %3E= 3) %7B%0A                        result.add(Arrays.asList(prevIdx, i - 1));%0A                    %7D%0A                    count = 1;%0A                    prevIdx = i;%0A                %7D%0A            %7D%0A        %7D%0A        if (count %3E= 3) %7B%0A            result.add(Arrays.asList(prevIdx, S.length() - 1));%0A        %7D%0A        return result;
 %0A   

Solve problem 830