less than 1 minute read

Given a binary tree root, invert it so that its left subtree and right subtree are swapped and the children are recursively inverted.

Constraints

  • n ≤ 100,000 where n is the number of nodes in root

https://binarysearch.com/problems/Invert-Tree

Examples

Example 1

Input

  • root =

Output

  • answer =

Solution

Leave a comment