InterviewBit Academy is now Scaler!
InterviewBit Academy is now Scaler Academy!

Invert the Binary Tree

Given a binary tree, invert the binary tree and return it.
Look at the example for more details.

Example :
Given binary tree

   /   \
  2     3
 / \   / \
4   5 6   7

invert and return

   /   \
  3     2
 / \   / \
7   6 5   4

NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Invert the Binary Tree on Interview Code Editor
Sign Up
to access hints and editorial solutions for Invert the Binary Tree
Asked In:


Click here to start solving coding interview questions