830. 较大分组的位置

class Solution {
   public List<List<Integer>> largeGroupPositions(String S) {
		List<List<Integer>> ls = new LinkedList<List<Integer>>();
		for (int i = 0; i < S.length() - 2; i++) {
			if (S.charAt(i) == S.charAt(i + 1) && S.charAt(i) == S.charAt(i + 2)) {
				char s = S.charAt(i);
				List<Integer> l = new LinkedList<Integer>();
				int a = i;
				int b = i;
				while (b<S.length()&&s == S.charAt(b)) {
					b++;
				}
				l.add(a);
				l.add(b-1);
				ls.add(l);
                i = b-1;
			}
		}
		return ls;

	}
}
原文地址:https://www.cnblogs.com/cznczai/p/11298241.html