Symmetric Tree

Given the root of a binary tree, determine whether the tree is symmetric around its center.

Constraints

  • The number of nodes in the tree is in the range [1, 1000].
  • -100 <= Node.val <= 100
Saving… · 10 lines
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right

class Solution:
def isSymmetric(self, root: TreeNode) -> bool:

Console

Click Run to execute sample tests.