Ignorer lints som ikke trengs
This commit is contained in:
parent
c09ac53fef
commit
d06e49bcd7
3 changed files with 32 additions and 2 deletions
|
|
@ -35,6 +35,34 @@ impl Solution {
|
|||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
fn test_max_depth() {
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
// Helper function to create a TreeNode
|
||||
fn new_node(
|
||||
val: i32,
|
||||
left: Option<Rc<RefCell<TreeNode>>>,
|
||||
right: Option<Rc<RefCell<TreeNode>>>,
|
||||
) -> Option<Rc<RefCell<TreeNode>>> {
|
||||
Some(Rc::new(RefCell::new(TreeNode { val, left, right })))
|
||||
}
|
||||
|
||||
// Constructing a simple tree:
|
||||
// 1
|
||||
// / \
|
||||
// 2 3
|
||||
// /
|
||||
// 4
|
||||
let tree = new_node(
|
||||
1,
|
||||
new_node(2, new_node(4, None, None), None),
|
||||
new_node(3, None, None),
|
||||
);
|
||||
|
||||
assert_eq!(Solution::max_depth(tree), 3);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println!("{:?}", test_max_depth());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue