码迷,mamicode.com
首页 > 其他好文 > 详细

[LeetCode] Find Duplicate Subtrees 寻找重复树

时间:2017-09-10 09:59:16      阅读:95      评论:0      收藏:0      [点我收藏+]

标签:each   val   ref   ret   question   script   one   following   tree   

 

Given a binary tree, return all duplicate subtrees. For each kind of duplicate subtrees, you only need to return the root node of any oneof them.

Two trees are duplicate if they have the same structure with same node values.

Example 1: 

        1
       /       2   3
     /   /     4   2   4
       /
      4
The following are two duplicate subtrees:
      2
     /
    4
and
    4
Therefore, you need to return above trees‘ root in the form of a list.

 

s

 

 

 

 

 

 

[LeetCode] Find Duplicate Subtrees 寻找重复树

标签:each   val   ref   ret   question   script   one   following   tree   

原文地址:http://www.cnblogs.com/grandyang/p/7500082.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!