#define NULL ((void *)0) //定义二叉树 struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; }; //递归 void inorder(struct TreeNode* root, int* res, int* resSize) { if (!root) return; inorder(root->left, res, resSize); res[(*resSize)++] = root->val; inorder(root->right, res, resSize); } int* inorderTraversal(struct TreeNode* root, int* returnSize) { int* res = malloc(sizeof(int) * 501); *returnSize = 0; inorder(root, res, returnSize); return res; }
每日LeetCode - 94. 二叉树的中序遍历(C语言)
原文:https://www.cnblogs.com/vicky2021/p/14799452.html