Skip to content
CodeShare
All problems

Symmetric Tree

Check whether a binary tree is a mirror of itself.

EasyTreesQueue

Given the root of a binary tree, return true if it's symmetric around its center: its left half is a mirror image of its right half.

Trees are written level by level, with null for a missing child.

Examples

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

Constraints

  • The tree has between 1 and 1000 nodes.
  • -100 <= Node.val <= 100