From 340051b2a6ebd9f90c2da3cc3d3bf9e729922194 Mon Sep 17 00:00:00 2001 From: Jianmin Chen Date: Fri, 19 Oct 2018 11:12:00 -0700 Subject: [PATCH] Update _687.java 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. --- src/main/java/com/fishercoder/solutions/_687.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/fishercoder/solutions/_687.java b/src/main/java/com/fishercoder/solutions/_687.java index 577b1e37d0..fdefefa727 100644 --- a/src/main/java/com/fishercoder/solutions/_687.java +++ b/src/main/java/com/fishercoder/solutions/_687.java @@ -47,7 +47,9 @@ public int longestUnivaluePath(TreeNode root) { } return result[0]; } - + + // calculate longest univalue path from root to leaves + // In addition, the maximum univalue path cross the root node is calculated and then global maximum is udpated. private int dfs(TreeNode root, int[] result) { int leftPath = root.left == null ? 0 : dfs(root.left, result); int rightPath = root.right == null ? 0 : dfs(root.right, result);