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

Commit960e2dd

Browse files
jianminchenfishercoder1534
authored andcommitted
Update _687.java (fishercoder1534#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 parent250459e commit960e2dd

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
returnresult[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
privateintdfs(TreeNoderoot,int[]result) {
5254
intleftPath =root.left ==null ?0 :dfs(root.left,result);
5355
intrightPath =root.right ==null ?0 :dfs(root.right,result);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp