Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd7d122e

Browse files
refactor 1022
1 parentee03f24 commitd7d122e

File tree

1 file changed

+0
-29
lines changed

1 file changed

+0
-29
lines changed

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

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,6 @@
55
importjava.util.ArrayList;
66
importjava.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
publicclass_1022 {
389
publicstaticclassSolution1 {
3910
publicintsumRootToLeaf(TreeNoderoot) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp