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

Commitbd52b29

Browse files
refactor 1273
1 parentb8e8777 commitbd52b29

File tree

1 file changed

+0
-26
lines changed

1 file changed

+0
-26
lines changed

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

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,6 @@
22

33
importjava.util.Arrays;
44

5-
/**
6-
* 1273. Delete Tree Nodes
7-
*
8-
* A tree rooted at node 0 is given as follows:
9-
* The number of nodes is nodes;
10-
* The value of the i-th node is value[i];
11-
* The parent of the i-th node is parent[i].
12-
* Remove every subtree whose sum of values of nodes is zero.
13-
* After doing so, return the number of nodes remaining in the tree.
14-
*
15-
* Example 1:
16-
* 0 (1)
17-
* / \
18-
* (-2) 1 2 (4)
19-
* / / | \
20-
* (0)3 (-2)4 (-1)5 6(-1)
21-
*
22-
* Input: nodes = 7, parent = [-1,0,0,1,2,2,2], value = [1,-2,4,0,-2,-1,-1]
23-
* Output: 2
24-
*
25-
* Constraints:
26-
* 1 <= nodes <= 10^4
27-
* -10^5 <= value[i] <= 10^5
28-
* parent.length == nodes
29-
* parent[0] == -1 which indicates that 0 is the root.
30-
* */
315
publicclass_1273 {
326
publicstaticclassSolution1 {
337
publicintdeleteTreeNodes(intnodes,int[]parent,int[]value) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp