【leetcode】1389. 按既定顺序创建目标数组
作者:互联网
/** * Note: The returned array must be malloced, assume caller calls free(). */ int* createTargetArray(int* nums, int numsSize, int* index, int indexSize, int* returnSize){ int* arr=(int*)calloc(numsSize,sizeof(int)); int i, j; for(i=0; i<indexSize; i++){ if(index[i] < i) for(j=i; j>index[i]; j--) arr[j]=arr[j-1]; arr[index[i]]=nums[i]; } *returnSize=numsSize; return arr; }
标签:numsSize,index,arr,returnSize,int,nums,1389,leetcode,既定 来源: https://www.cnblogs.com/ganxiang/p/14028664.html