Skip to content

Commit 5663b52

Browse files
add 2331
1 parent ff116c7 commit 5663b52

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|------|----------------|------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|----------------------------------|-------------
11+
| 2331 |[Evaluate Boolean Binary Tree](https://leetcode.com/problems/evaluate-boolean-binary-tree/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2331.java) || Easy ||
1112
| 2326 |[Spiral Matrix IV](https://leetcode.com/problems/spiral-matrix-iv/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2326.java) || Medium ||
1213
| 2325 |[Decode the Message](https://leetcode.com/problems/decode-the-message/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2325.java) || Easy ||
1314
| 2319 |[Check if Matrix Is X-Matrix](https://leetcode.com/problems/check-if-matrix-is-x-matrix/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2319.java) || Easy ||
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.fishercoder.solutions;
2+
3+
import com.fishercoder.common.classes.TreeNode;
4+
5+
public class _2331 {
6+
public static class Solution1 {
7+
public boolean evaluateTree(TreeNode root) {
8+
if (root == null) {
9+
return true;
10+
}
11+
if (root.left == null && root.right == null) {
12+
if (root.val == 0) {
13+
return false;
14+
} else {
15+
return true;
16+
}
17+
}
18+
if (root.val == 2) {
19+
return evaluateTree(root.left) || evaluateTree(root.right);
20+
} else {
21+
return evaluateTree(root.left) && evaluateTree(root.right);
22+
}
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy