Symmetric Tree

Difficulty: Easy | Category: Tree | Asked at: Microsoft | Platform: Unfoldd Arena

### 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

Solve Symmetric Tree online for free in Python, JavaScript, Java, C++, TypeScript, Go, Rust, PHP, Swift, Kotlin, Dart, Ruby, C, and C#. Practice Easy level coding interview problems with instant test case evaluation and AI-powered analysis.

Keywords: Symmetric Tree solution, Symmetric Tree leetcode, Symmetric Tree python, Symmetric Tree javascript,Symmetric Tree java, Symmetric Tree approach, how to solve Symmetric Tree, easy coding problems, Tree problems, coding interview preparation, DSA practice free.

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.