二叉树刷题记录
int maxDepth(struct TreeNode* root){
int m,n;
m = n = 0;
if(root == NULL){
return 0;
}
m = maxDepth(root->left);
n = maxDepth(root->right);
if(m > n){
return m+1;
}else{
return n+1;
}
}
void inorder (struct TreeNode* root, int* res, int* resSize){
if(root == NULL){
return;
}
res[(*resSize)++] = root->val;
inorder(root->left,res,resSize);
inorder(root->right,res,resSize);
}
int*
二叉树刷题记录最先出现在Python成神之路。
共有 0 条评论