/**
* Note: The returned array must be malloced, assume caller calls free().
*/
int* pivotArray(int* nums, int numsSize, int pivot, int* returnSize){
*returnSize=numsSize;
int lessthan[100000];
int top1=0;
int beequalto[100000];
int top2=0;
int greaterthan[100000];
int top3=0;
for(int a=0;a<numsSize;a++){
if(nums[a]<pivot){
lessthan[top1++]=nums[a];
}
else if(nums[a]==pivot){
beequalto[top2++]=nums[a];
}
else{
greaterthan[top3++]=nums[a];
}
}
for(int a=0;a<top1;a++){
nums[a]=lessthan[a];
}
for(int a=top1;a<top1+top2;a++){
nums[a]=beequalto[a-top1];
}
for(int a=top1+top2;a<top1+top2+top3;a++){
nums[a]=greaterthan[a-top1-top2];
}
return nums;
}
10-25
141
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
02-20
498
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
11-09
4980
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
03-25
3万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)