热门

最新

红包

立Flag

投票

同城

我的

发布
weixin_48568923
想下一行代码ing
2 年前
trueweixin_48568923

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

CSDN App 扫码分享
分享
评论
1
打赏
  • 复制链接
  • 举报
下一条:
什么时候开始,你不再谦逊了?什么时候开始,你不再敬畏了?骄傲自大,盲目自信,永远是敌人!
立即登录