Back to all patterns

Tree DFS with Global Variable

1 problems • Practice on LeetCode to earn credits

About This Pattern

Master the Tree DFS with Global Variable 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)

Diameter of Binary Tree

Find the diameter (longest path between any two nodes) of a binary tree.

Key Signals:

Calculate heightDiameter at each node = left + right heightTrack maximum