TheAlgorithms-C/leetcode/src/94.c
2019-09-26 08:29:31 -07:00

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;
}