513. Find Bottom Left Tree Value
来源:互联网 发布:adc0808数据手册 编辑:程序博客网 时间:2024/06/06 01:46
Given a binary tree, find the leftmost value in the last row of the tree.
Example 1:
Input:
2
/ \
1 3
Output:
1
Example 2:
Input:
1
/ \
2 3
/ / \
4 5 6
/
7
Output:
7
Example 1:
Input:
2
/ \
1 3
Output:
1
Example 2:
Input:
1
/ \
2 3
/ / \
4 5 6
/
7
Output:
7
Note: You may assume the tree (i.e., the given root node) is not NULL.
class Solution {public: int findBottomLeftValue(TreeNode* root) { vector<int> res(2, 0); return helper(root, 1, res); } int helper(TreeNode* root, int depth, vector<int>& res){ if(depth>res[1]){res[0]=root->val; res[1]=depth;} if(root->left) helper(root->left, depth+1, res); if(root->right) helper(root->right, depth+1, res); return res[0]; } };
0 0
- LeetCode 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
- 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
- Leetcode 513. Find Bottom Left Tree Value
- LeetCode 513. Find Bottom Left Tree Value
- [DFS]513. 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 | LeetCode
- 513. Find Bottom Left Tree Value
- js中cookie的使用详细分析
- 为什么“-1”能作为判断文本文件结束的标志然而为什么不能作为二进制文件是否结束的标志?
- 资源——方法,策略——能力
- Java Annotation实例:使用Annontaion简化开发
- C# StringBuilder
- 513. Find Bottom Left Tree Value
- mysql千万级数据库插入速度和读取速度的调整记录
- Opencv学习笔记(二)———Opencv3中ORB算法的使用
- 登录表单验证前后端
- border-radius 50%和100%的区别
- Android属性allowBackup安全风险浅析
- jdk1.7换为1.8 java -version 仍为1.7
- 在 Ubuntu 16.04 LTS 上安装 Python 3.6.0
- iOS 获取当前正在显示的ViewController