【leetcode】圆形赛道上经过次数最多的扇区

 

int* mostVisited(int n, int* rounds, int roundsSize, int* returnSize){
    int i,pst=0;
    int* arr = (int*)calloc(n,sizeof(int));
    if (rounds[roundsSize-1] >= rounds[0]){
        for (i=rounds[0]; i<=rounds[roundsSize-1]; i++) 
            arr[pst++] = i;
    }
    else{
        for (i=1; i<=n; i++)
            if (i<= rounds[roundsSize-1] || i>=rounds[0]) arr[pst++] = i;
    }
    *returnSize = pst;
    return arr;
}

 

posted @ 2020-09-16 13:23  温暖了寂寞  阅读(146)  评论(0编辑  收藏  举报