515. Find Largest Value in Each Tree Row Medium
1/**
2 * [515] Find Largest Value in Each Tree Row
3 *
4 * Given the root of a binary tree, return an array of the largest value in each row of the tree (0-indexed).
5 *
6 * Example 1:
7 * <img alt="" src="https://assets.leetcode.com/uploads/2020/08/21/largest_e1.jpg" style="width: 300px; height: 172px;" />
8 * Input: root = [1,3,2,5,3,null,9]
9 * Output: [1,3,9]
10 *
11 * Example 2:
12 *
13 * Input: root = [1,2,3]
14 * Output: [1,3]
15 *
16 *
17 * Constraints:
18 *
19 * The number of nodes in the tree will be in the range [0, 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-largest-value-in-each-tree-row/
27// discuss: https://leetcode.com/problems/find-largest-value-in-each-tree-row/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 largest_values(root: Option<Rc<RefCell<TreeNode>>>) -> Vec<i32> {
53 vec![]
54 }
55}
56
57// submission codes end
58
59#[cfg(test)]
60mod tests {
61 use super::*;
62
63 #[test]
64 fn test_515() {
65 }
66}
67
Back
© 2025 bowen.ge All Rights Reserved.