Binary Tree · DFS / BFS · LC 101
Symmetric Tree
Check whether a binary tree is a mirror of itself - left subtree mirrors the right subtree at every level.
Key concepts at a glance — for those who already know the basics.
Problem Statement
Given the root of a binary tree, determine whether it is symmetric around its center.
Symmetric means left and right subtrees are mirror images with matching structure and matching values at mirrored positions.
Example: [1,2,2,3,4,4,3] => true, [1,2,2,null,3,null,3] => false
01 · The rule
A tree is symmetric if its left and right subtrees are mirrors of each other
Two subtrees are mirrors when: their roots have equal values, the left child of one equals the right child of the other, and vice versa - checked recursively all the way down.
02 · How to think
isMirror(left, right) with root.left and root.right.None -> symmetric. One None, one not -> asymmetric. Both exist -> compare values.left.left vs right.right. Inner: left.right vs right.left. Both must pass.03 · Code (Python)
04 · Example tree & mirror check
05 · Complexity
Try it yourself
LeetCode 101 · Easy · Tags: Tree, DFS, BFS, Binary Tree