We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 44aeeb1 commit f97c1e0Copy full SHA for f97c1e0
src/main/java/com/fishercoder/solutions/_652.java
@@ -31,6 +31,10 @@
31
public class _652 {
32
33
/**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.*/
38
public List<TreeNode> findDuplicateSubtrees(TreeNode root) {
39
List<TreeNode> res = new LinkedList<>();
40
postorder(root, new HashMap<>(), res);
0 commit comments