
3.6K
SKCan you merge two trees without getting confused? 🌳
LeetCode 617 – Merge Two Binary Trees 🌳
You’re given two binary trees.
Merge them using this rule:
✔ If both nodes exist → sum their values
✔ If one node is null → take the non-null node
This is a classic recursion pattern.
Time Complexity: O(n)
(Visit each node once)
📦 Space Complexity: O(h)
(h = tree height, recursion stack)
Simple. Elegant. Interview favorite.
Save this for your tree revision 📌
#leetcode #dsa #binarytree
#recursion #coding
@skills2salary










