java.lang.Object
g0601_0700.s0652_find_duplicate_subtrees.Solution

public class Solution extends Object
652 - Find Duplicate Subtrees.<p>Medium</p> <p>Given the <code>root</code> of a binary tree, return all <strong>duplicate subtrees</strong>.</p> <p>For each kind of duplicate subtrees, you only need to return the root node of any <strong>one</strong> of them.</p> <p>Two trees are <strong>duplicate</strong> if they have the <strong>same structure</strong> with the <strong>same node values</strong>.</p> <p><strong>Example 1:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2020/08/16/e1.jpg" alt="" /></p> <p><strong>Input:</strong> root = [1,2,3,4,null,2,4,null,null,4]</p> <p><strong>Output:</strong> [[2,4],[4]]</p> <p><strong>Example 2:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2020/08/16/e2.jpg" alt="" /></p> <p><strong>Input:</strong> root = [2,1,1]</p> <p><strong>Output:</strong> <a href="1">1</a></p> <p><strong>Example 3:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2020/08/16/e33.jpg" alt="" /></p> <p><strong>Input:</strong> root = [2,2,2,3,null,3,null]</p> <p><strong>Output:</strong> [[2,3],[3]]</p> <p><strong>Constraints:</strong></p> <ul> <li>The number of the nodes in the tree will be in the range <code>[1, 10^4]</code></li> <li><code>-200 <= Node.val <= 200</code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details