/**
* Note: The returned array must be malloced, assume caller calls free().
*/
char ** buildArray(int* target, int targetSize, int n, int* returnSize){
*returnSize=0;
char **ans=(char**)calloc(200,sizeof(char*));
int b=0;
for(int a=1;a<=n;a++){
ans[*returnSize]=(char*)calloc(5,sizeof(char));
strcpy(ans[*returnSize], "Push\0");
*returnSize=*returnSize+1;
if(target[b]!=a){
ans[*returnSize]=(char*)calloc(4,sizeof(char));
strcpy(ans[*returnSize], "Pop\0");
*returnSize=*returnSize+1;
}
else{
b++;
}
if(b==targetSize){
break;
}
}
return ans;
}
力扣------用栈操作构建数组
最新推荐文章于 2024-07-25 21:13:04 发布