Skip to content

Commit d7d122e

Browse files
refactor 1022
1 parent ee03f24 commit d7d122e

File tree

1 file changed

+0
-29
lines changed

1 file changed

+0
-29
lines changed

src/main/java/com/fishercoder/solutions/_1022.java

-29
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,6 @@
55
import java.util.ArrayList;
66
import java.util.List;
77

8-
/**
9-
* Source: https://leetcode.com/problems/sum-of-root-to-leaf-binary-numbers/
10-
*
11-
* 1022. Sum of Root To Leaf Binary Numbers
12-
*
13-
* Given a binary tree, each node has value 0 or 1. Each root-to-leaf path represents a binary number starting with the most significant bit. For example, if the path is 0 -> 1 -> 1 -> 0 -> 1, then this could represent 01101 in binary, which is 13.
14-
*
15-
* For all leaves in the tree, consider the numbers represented by the path from the root to that leaf.
16-
*
17-
* Return the sum of these numbers.
18-
*
19-
* Example 1:
20-
*
21-
* 1
22-
* / \
23-
* 0 1
24-
* / \ / \
25-
* 0 1 0 1
26-
*
27-
* Input: [1,0,1,0,1,0,1]
28-
* Output: 22
29-
* Explanation: (100) + (101) + (110) + (111) = 4 + 5 + 6 + 7 = 22
30-
*
31-
* Note:
32-
*
33-
* The number of nodes in the tree is between 1 and 1000.
34-
* node.val is 0 or 1.
35-
* The answer will not exceed 2^31 - 1.
36-
* */
378
public class _1022 {
389
public static class Solution1 {
3910
public int sumRootToLeaf(TreeNode root) {

0 commit comments

Comments
 (0)