版权声明:原创勿转 https://cloud.tencent.com/developer/article/1420467
思路
直接按照题目的意思求解
code
代码语言:javascript复制func largeGroupPositions(S string) [][]int {
ret := [][]int{}
i, j := 0, 0
for i < len(S) {
for j < len(S) && S[i] == S[j] {
j
}
if j-i >= 3 {
tmp := []int{i, j - 1}
ret = append(ret, tmp)
}
i = j
}
return ret
}