【leetcode】有多少小于当前数字的数字
int cmp(const void* a,const void* b){ return *(int*)a > *(int*)b; } int* smallerNumbersThanCurrent(int* nums, int numsSize, int* returnSize){ int hash[101]={0}; int temp[501]; int i; memcpy(temp,nums,numsSize*sizeof(int)); qsort(temp,numsSize,sizeof(int),cmp); for (i=1; i<numsSize; i++) if (temp[i] != temp[i-1]) hash[temp[i]]=i; for (i=0; i<numsSize; i++) nums[i] = hash[nums[i]]; *returnSize=numsSize; return nums; }