Back to all patterns

Tree DFS

2 problems • Practice on LeetCode to earn credits

About This Pattern

Master the Tree DFS pattern by practicing these problems organized by difficulty.Focus on the Key Signals - these are the indicators that tell you when to use this pattern.

Easy (1)

Same Tree

Check if two binary trees are structurally identical with same values.

Key Signals:

Parallel traversalCompare values and structureBase cases for null

Medium (1)

Lowest Common Ancestor of a Binary Tree

Find the lowest common ancestor of two nodes in a binary tree.

Key Signals:

Post-order traversalLCA problemRecursive search