【leetcode】重新排列数组

时间:2020-09-17 15:41:19   收藏:0   阅读:21

 

int* shuffle(int* nums, int numsSize, int n, int* returnSize){
    int* arr = (int*)calloc(numsSize, sizeof(int));
    int pst = 0;
    for (int i = 0; i < numsSize/2; i++)
    {
        arr[pst++] = nums[i];
        arr[pst++] = nums[i+n];
    }
    *returnSize = numsSize;
    return arr;
}

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!