mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08:00
16 lines
430 B
C
16 lines
430 B
C
void processTraversal(struct TreeNode *root, int *res, int *size) {
|
|
if(!root)
|
|
return;
|
|
processTraversal(root->left, res, size);
|
|
res[*size] = root->val;
|
|
*size = *size + 1;
|
|
processTraversal(root->right, res, size);
|
|
}
|
|
|
|
int* inorderTraversal(struct TreeNode* root, int* returnSize){
|
|
int *res = malloc(256*sizeof(int));
|
|
*returnSize = 0;
|
|
processTraversal(root, res, returnSize);
|
|
return res;
|
|
}
|