Skip to main content
Easy Trees / DFS High frequency

Symmetric Tree

Open on LeetCode

Approach Summary

Recursively compare left subtree's right children with right subtree's left children. Both must mirror each other.

How to Recognize This Pattern

  • "Is the tree a mirror of itself"
  • Compare outer-outer and inner-inner pairs simultaneously

Complexity Analysis

Time Complexity

O(n)

Space Complexity

O(h)

Tags

Tree DFS BFS Binary Tree

This site is free. If these guides are helping your prep, consider buying me a coffee. ☕

Support →
Buy me a coffee