Symmetric Tree Problem

Symmetric Tree Problem — ExecCode Medium DSA Practice

Solve the Symmetric Tree problem on ExecCode. Free online medium DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Given the root of a binary tree, check whether it is a mirror of itself — that is, whether it is symmetric around its vertical center line. Two subtrees are mirrors of each other when their root values match and each one's left subtree mirrors the other's right subtree.

Examples

Input root = [1, 2, 2, 3, 4, 4, 3]; Output true. Input root = [1, 2, 2, null, 3, null, 3]; Output false. Input root = [1]; Output true

Constraints

The number of nodes in the tree is in the range [1, 1000]. -100 <= Node.val <= 100

Practice Symmetric Tree free on ExecCode. Browse DSA problems, topic map, and placement guides.