We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c1a4fa7 commit 4c2221cCopy full SHA for 4c2221c
src/main/java/com/fishercoder/solutions/_543.java
@@ -27,10 +27,10 @@ private int dfs(TreeNode root) {
27
if (root == null) {
28
return 0;
29
}
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;
+ int leftPath = dfs(root.left);
+ int rightPath = dfs(root.right);
+ diameter = Math.max(diameter, leftPath + rightPath);
+ return Math.max(leftPath, rightPath) + 1;
34
35
36
0 commit comments