513. Find Bottom Left Tree Value Medium

@problem@discussion
#Tree#Depth-First Search#Breadth-First Search#Binary Tree



1/**
2 * [513] Find Bottom Left Tree Value
3 *
4 * Given the root of a binary tree, return the leftmost value in the last row of the tree.
5 *  
6 * Example 1:
7 * <img alt="" src="https://assets.leetcode.com/uploads/2020/12/14/tree1.jpg" style="width: 302px; height: 182px;" />
8 * Input: root = [2,1,3]
9 * Output: 1
10 * 
11 * Example 2:
12 * <img alt="" src="https://assets.leetcode.com/uploads/2020/12/14/tree2.jpg" style="width: 432px; height: 421px;" />
13 * Input: root = [1,2,3,4,null,5,6,null,null,7]
14 * Output: 7
15 * 
16 *  
17 * Constraints:
18 * 
19 * 	The number of nodes in the tree is in the range [1, 10^4].
20 * 	-2^31 <= Node.val <= 2^31 - 1
21 * 
22 */
23pub struct Solution {}
24use crate::util::tree::{TreeNode, to_tree};
25
26// problem: https://leetcode.com/problems/find-bottom-left-tree-value/
27// discuss: https://leetcode.com/problems/find-bottom-left-tree-value/discuss/?currentPage=1&orderBy=most_votes&query=
28
29// submission codes start here
30
31// Definition for a binary tree node.
32// #[derive(Debug, PartialEq, Eq)]
33// pub struct TreeNode {
34//   pub val: i32,
35//   pub left: Option<Rc<RefCell<TreeNode>>>,
36//   pub right: Option<Rc<RefCell<TreeNode>>>,
37// }
38// 
39// impl TreeNode {
40//   #[inline]
41//   pub fn new(val: i32) -> Self {
42//     TreeNode {
43//       val,
44//       left: None,
45//       right: None
46//     }
47//   }
48// }
49use std::rc::Rc;
50use std::cell::RefCell;
51impl Solution {
52    pub fn find_bottom_left_value(root: Option<Rc<RefCell<TreeNode>>>) -> i32 {
53        0
54    }
55}
56
57// submission codes end
58
59#[cfg(test)]
60mod tests {
61    use super::*;
62
63    #[test]
64    fn test_513() {
65    }
66}
67


Back
© 2025 bowen.ge All Rights Reserved.