Data Structures19 sections · 729 units
Open in Course

Problem - Symmetric Tree

Is it a mirror of itself?

Given the root of a binary tree, check whether it is a mirror of itself (symmetric around its center). Example: [1,2,2,3,4,4,3][1,2,2,3,4,4,3] is symmetric. [1,2,2,null,3,null,3][1,2,2,null,3,null,3] is not.

This problem combines ideas from "same tree" and "invert tree." A tree is symmetric if its left subtree is a mirror of its right subtree. Constraints: up to 10001000 nodes, values from 100-100 to 100100.