Symmetric Tree

Easy

Problem: Symmetric Tree

Problem Statement

Given the root of a binary tree, determine if the tree is symmetric. A binary tree is symmetric if the left subtree is a mirror reflection of the right subtree.

Rules and Constraints

  • A binary tree node has a value and two children (left child and right child).
  • You can only access the root node from the top level of the tree.
  • The nodes are connected by edges from parent to child.
  • You are given a function to get the root of the tree.
  • The time complexity of your solution should be O(n), where n is the number of nodes in the tree.
  • The space complexity of your solution should be O(h), where h is the height of the tree.

Example

Input: {"root":[1,2,2,3,4,4,3]} Output: true

CompaniesMicrosoft
JavaScript

Login to write code

Solve problems, verify your skills, and earn XP.