Skip to content

Commit 4c2221c

Browse files
refactor 543
1 parent c1a4fa7 commit 4c2221c

File tree

1 file changed

+4
-4
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+4
-4
lines changed

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ private int dfs(TreeNode root) {
2727
if (root == null) {
2828
return 0;
2929
}
30-
int left = dfs(root.left);
31-
int right = dfs(root.right);
32-
diameter = Math.max(diameter, left + right);
33-
return Math.max(left, right) + 1;
30+
int leftPath = dfs(root.left);
31+
int rightPath = dfs(root.right);
32+
diameter = Math.max(diameter, leftPath + rightPath);
33+
return Math.max(leftPath, rightPath) + 1;
3434
}
3535
}
3636
}

0 commit comments

Comments
 (0)