首页 > 其他 > 详细

[LeetCode] Longest Univalue Path 最长相同值路径

时间:2017-10-08 00:51:10      阅读:890      评论:0      收藏:0      [点我收藏+]

 

Given a binary tree, find the length of the longest path where each node in the path has the same value. This path may or may not pass through the root.

Note: The length of path between two nodes is represented by the number of edges between them.

Example 1:

Input:

              5
             /             4   5
           / \             1   1   5

 

Output:

2

 

Example 2:

Input:

              1
             /             4   5
           / \             4   4   5

 

Output:

2

 

Note: The given binary tree has not more than 10000 nodes. The height of the tree is not more than 1000.

 

s

 

[LeetCode] Longest Univalue Path 最长相同值路径

原文:http://www.cnblogs.com/grandyang/p/7636259.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!