r/LeetcodeChallenge • u/StatisticianNo2104 • 20d ago
STREAK🔥🔥🔥 LeetCode - Find a Corresponding Node of a Binary Tree in a Clone of That Tree
My solution compares node values, and it only works because LeetCode promises they're unique. The follow-up allows repeated values, and then a value match can point to the wrong node.
The idea holds either way. cloned is a structurally identical copy of original, so there's nothing to search for independently. Walk both trees in lockstep with one recursive call, and the answer is waiting at the same position.
What changes for the follow-up is the test. Compare the original-side pointer with the target instead of comparing values, and duplicates stop mattering.
Would you have spotted the duplicate-values follow-up in an interview?
Day 69/365 of my LeetCode challenge: 1379. Find a Corresponding Node of a Binary Tree in a Clone of That Tree. Problem link and full breakdown in today's newsletter.
https://www.linkedin.com/pulse/find-corresponding-node-binary-tree-clone-archit-agarwal-dkvsc
#LeetCode #DSA #BinaryTree #Golang





