ExamAdda Logo

Symmetric Tree

Easy

Given the root of a binary tree, determine whether the tree is symmetric around its center.

A binary tree is symmetric if its left subtree is a mirror reflection of its right subtree.

Example 1

Input

root = [1,2,2,3,4,4,3]

Output

true

Explanation

The left and right subtrees are mirror images of each other.

Example 2

Input

root = [1,2,2,null,3,null,3]

Output

false

Explanation

The two subtrees have different structures, so the tree is not symmetric.

Constraints

0 <= number of nodes <= 1000
-100 <= Node.val <= 100

Hints:

Hint 1

A tree is symmetric if its left and right subtrees are mirror images.

Hint 2

Compare the left child of one node with the right child of the other node.

Author & Technical Reviewer

ExamAdda Technical Review Team

Technically reviewed by: ExamAdda Technical Review Team

Technical Reviewers, ExamAdda

Software engineers at ExamAdda who check every article's definitions, complexity claims and code examples before and after publishing.

Published

Aug 11, 2026

Last updated

Aug 12, 2026

Content Verification Methodology

Definitions and complexity claims were checked against authoritative computer-science references. Code examples were compiled and tested with standard, boundary and edge-case inputs.

Report a correction:editorial@examadda.org
Auto
Loading editor...
Input

Expected Output