Skip to content

Commit f97c1e0

Browse files
edit 652
1 parent 44aeeb1 commit f97c1e0

File tree

1 file changed

+4
-0
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+4
-0
lines changed

src/main/java/com/fishercoder/solutions/_652.java

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
public class _652 {
3232

3333
/**credit: https://discuss.leetcode.com/topic/97584/java-concise-postorder-traversal-solution*/
34+
35+
/**You don't actually need to check if every other tree is a duplicate of current node,
36+
* just when you go through each node, you'll see whether there's already one in the map,
37+
* since map.containsKey() checks this TreeNode.*/
3438
public List<TreeNode> findDuplicateSubtrees(TreeNode root) {
3539
List<TreeNode> res = new LinkedList<>();
3640
postorder(root, new HashMap<>(), res);

0 commit comments

Comments
 (0)