Find Bottom Left Tree Value
来源:互联网 发布:网络成瘾的影响 编辑:程序博客网 时间:2024/05/29 15:13
思路:建立一个有2个元素的vector,第一个元素存放叶子的深度,第二个叶子存放元素值
vector<int> Fun(int level,TreeNode* node)
{vector<int> res(2,0);
if (node==NULL)
return res;
if (node->left==NULL&&node->right==NULL)
{
res[0]=level;
res[1]=node->val;
return res;
}
vector<int> tmpl(2),tmpr(2);
tmpl=Fun(level+1,node->left);
tmpr=Fun(level+1,node->right);
if (tmpl[0]>=tmpr[0]) //比较两个叶子的深度
res=tmpl;
else
res=tmpr;
return res;
}
int findBottomLeftValue(TreeNode* root) {
vector<int> res(2,0);
res=Fun(1,root);
return res.back();
0 0
- Find Bottom Left Tree Value
- Find Bottom Left Tree Value
- Find Bottom Left Tree Value
- Find Bottom Left Tree Value
- Find Bottom Left Tree Value
- Find Bottom Left Tree Value
- Find Bottom Left Tree Value
- Find Bottom Left Tree Value
- Find Bottom Left Tree Value
- Find Bottom Left Tree Value
- Find Bottom Left Tree Value
- LeetCode 513. Find Bottom Left Tree Value
- 513:find bottom left tree value
- [leetcode]513. Find Bottom Left Tree Value
- 513. Find Bottom Left Tree Value
- 513. Find Bottom Left Tree Value
- [leetcode] 513. Find Bottom Left Tree Value
- 513. Find Bottom Left Tree Value
- PHP定时任务实现和Linux crontab定时任务
- 295. Find Median from Data Stream***
- 【CodeForces 779A】Pupils Redistribution(模拟)
- bash: sqlplus: command not found 解决方法
- unity 2D中常见的角色移动同时防止角色二段跳
- Find Bottom Left Tree Value
- Android属性allowBackup安全风险浅析
- 【Activiti工作流】4.准备开发环境(配置文件)和核心api的介绍
- 00003 不思议迷宫.0010.1.1:csb解析显示
- Android开发之在不同API上遇见的坑
- python3.6安装+beautifulsoup4-4.5.1安装+lxml+html5lib+requests安装
- 222. Count Complete Tree Nodes
- 北大 C++ 2.3 从客观事物抽象出类的例子
- C++11 sort using function objects