leetcode 513.寻找二叉树左下角的值
int maxdepth=-1;
int result=0;
void minleft(struct TreeNode* root,int depth)
{
if(root->left==NULL&&root->right==NULL)
{
if(depth>maxdepth)
{
maxdepth=depth;
result=root->val;
}
return;
}
if(root->left)
{
minleft(root->left,depth+1);
}
if(root->right)
{
minleft(root->right,depth+1);
}
}
int findBottomLeftValue(struct TreeNode* root) {
int depth=0;
maxdepth=-1;
result=0;
minleft(root,depth);
return result;
}