830. 较大分组的位置
Posted cznczai
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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;
以上是关于830. 较大分组的位置的主要内容,如果未能解决你的问题,请参考以下文章
算法千题案例每日LeetCode打卡——100.较大分组的位置
按日期间隔大于 X 的 DATETIME 获取数据、计数和分组