Diwali Offer!Flat 20% OFF
Enroll Now
PrakalpanaLive online tech training

114. Invert Binary Tree

EasyDay 34 of 60Trees & BST

Given the root of a binary tree, mirror it: swap the left and right child of every node. Return the root of the mirrored tree.

Example 1
Input: root = [4,2,7,1,3,6,9]
Output: [4,7,2,9,6,3,1]
Example 2
Input: root = [2,1,3]
Output: [2,3,1]
Constraints
  • The number of nodes is in the range 0 to 100
  • -100 <= Node.val <= 100
Hints
Frequently asked at: Google, Amazon, Adobe
Ctrl + Enter runs the examples

Not sure what to learn next?

A 1-on-1 session with an industry mentor and a roadmap built for you. How it works

  1. 1Discuss your goals
  2. 2Get a personal plan
  3. 3Start learning
Book for β‚Ή200/ 30 min