Graph Theory37 sections · 1633 units
Open in Course

LeetCode 100 Same Tree - Lessons

Key patterns for tree comparison

This problem teaches you to walk two data structures in parallel. You do not process one tree and then the other. You process them together, node by node. The pattern appears in many tree comparison problems: checking symmetry, finding common subtrees, or merging trees.

You need to mirror your recursive calls on both inputs. Remember to handle all combinations of null and non-null. Missing an edge case here causes bugs. Check both-null, one-null, and both-exist separately.