File tree 3 files changed +19
-0
lines changed
3 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -568,6 +568,7 @@ leetcode_solutions
568
568
| 2299| [ Strong Password Checker II] ( https://leetcode.cn/problems/strong-password-checker-ii/ ) | [ Rust] ( src/easy/leetcode_very_easy.rs ) |
569
569
| 2319| [ Check If Matrix...] ( https://leetcode.cn/problems/check-if-matrix-is-x-matrix/ ) | [ Rust] ( src/easy/leetcode_very_easy.rs ) |
570
570
| 2325| [ Decode The Message] ( https://leetcode.cn/problems/decode-the-message/ ) | [ Rust] ( src/easy/leetcode_very_easy.rs ) |
571
+ | 2331| [ Evaluate Boolean Binary Tree] ( https://leetcode.cn/problems/evaluate-boolean-binary-tree/ ) | [ Rust] ( src/binary_tree/evaluate_boolean_binary_tree.rs ) |
571
572
572
573
---
573
574
Original file line number Diff line number Diff line change
1
+ use super :: prelude:: * ;
2
+
3
+ /// https://leetcode.cn/problems/evaluate-boolean-binary-tree/
4
+ fn evaluate_tree ( root : Option < Rc < RefCell < TreeNode > > > ) -> bool {
5
+ let root = root. unwrap ( ) ;
6
+ let root = root. borrow ( ) ;
7
+ if root. left . is_none ( ) && root. right . is_none ( ) {
8
+ return root. val == 1 ;
9
+ }
10
+ let left = evaluate_tree ( root. left . clone ( ) ) ;
11
+ let right = evaluate_tree ( root. right . clone ( ) ) ;
12
+ if root. val == 2 {
13
+ left || right
14
+ } else {
15
+ left && right
16
+ }
17
+ }
Original file line number Diff line number Diff line change
1
+ mod evaluate_boolean_binary_tree;
1
2
#[ cfg( feature = "rustc_private" ) ]
2
3
mod graphviz_view_leetcode_binary_tree;
3
4
mod invert_binary_tree;
You can’t perform that action at this time.
0 commit comments