Skip to content

Commit d9d4ec6

Browse files
solves #2236: Root Equals Sum of Children in java
1 parent d831362 commit d9d4ec6

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
out
33
venv
44
*.iml
5+
.DS_Store

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@
727727
| 2229 | 🔒 [Check if an array is consecutive](https://leetcode.com/problems/check-if-an-array-is-consecutive) | | |
728728
| 2231 | [Largest Number After Digit Swaps by Parity](https://leetcode.com/problems/largest-number-after-digit-swaps-by-parity) | [![Java](assets/java.png)](src/LargestNumberAfterDigitSwapsByParity.java) | |
729729
| 2235 | [Add Two Integers](https://leetcode.com/problems/add-two-integers) | [![Java](assets/java.png)](src/AddTwoIntegers.java) | |
730-
| 2236 | [Root Equals Sum of Children](https://leetcode.com/problems/root-equals-sum-of-children) | | |
730+
| 2236 | [Root Equals Sum of Children](https://leetcode.com/problems/root-equals-sum-of-children) | [![Java](assets/java.png)](src/RootEqualsSumOfChildren.java) | |
731731
| 2239 | [Find Closest Number to Zero](https://leetcode.com/problems/find-closest-number-to-zero) | | |
732732
| 2243 | [Calculate Digit Sum of a String](https://leetcode.com/problems/calculate-digit-sum-of-a-string) | | |
733733
| 2248 | [Intersection of Multiple Arrays](https://leetcode.com/problems/intersection-of-multiple-arrays) | | |

Diff for: src/RootEqualsSumOfChildren.java

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// https://leetcode.com/problems/root-equals-sum-of-children
2+
// T: O(1)
3+
// S: O(1)
4+
5+
public class RootEqualsSumOfChildren {
6+
public boolean checkTree(TreeNode root) {
7+
return root.val == root.left.val + root.right.val;
8+
}
9+
}

0 commit comments

Comments
 (0)