【leetcode】较大分组的位置

int** largeGroupPositions(char * s, int* returnSize, int** returnColumnSizes){
    int len = strlen(s);
    int** arr = (int**)calloc(len/3,sizeof(int*));
    int i,j=0,pre=0;
    for (i=1; i<=len; i++)
    {
        if (s[i] != s[i-1]) 
        {
            if (i-pre >= 3)
            {
                int* row = (int*)calloc(2,sizeof(int*));
                row[0]=pre;
                row[1]=i-1;
                arr[j] = row;
                (*returnColumnSizes)[j++]=2;
            }
            pre = i;
        }
    }
    *returnSize = j;
    return arr;
}
原文地址:https://www.cnblogs.com/ganxiang/p/13656034.html