Easy · Trees

Is symmetric

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

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Trees problems