Skip to content

Commit 15c6ec1

Browse files
jianminchenfishercoder1534
authored andcommitted
Update _687.java (#25)
change dfs function name to meaningful name, calculateLongestUnivaluePathFromRootToLeaves, and also additional calculation of max univalue path cross the root node should be specified somehow, one or two comments should be very helpful.
1 parent b3d904f commit 15c6ec1

File tree

1 file changed

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

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ public int longestUnivaluePath(TreeNode root) {
4747
}
4848
return result[0];
4949
}
50-
50+
51+
// calculate longest univalue path from root to leaves
52+
// In addition, the maximum univalue path cross the root node is calculated and then global maximum is udpated.
5153
private int dfs(TreeNode root, int[] result) {
5254
int leftPath = root.left == null ? 0 : dfs(root.left, result);
5355
int rightPath = root.right == null ? 0 : dfs(root.right, result);

0 commit comments

Comments
 (0)