Easy · Trees

Symmetric Tree

Given the root of a binary tree, return true if the tree is a mirror image of itself around its center (its left subtree mirrors its right subtree in shape and values) and false otherwise. An empty tree is symmetric.

Examples

Example 1

[1,2,2,3,4,4,3] symmetric

Output: symmetric

Example 2

[1,2,2,·,3,·,3] not symmetric

Output: not symmetric

Rebuild it in the studio

Core interview problems are free with a full runner and lessons; Pro opens the complete library.

More Trees problems