Problem Description
Given a binary tree A, invert the binary tree and return it.
Inverting refers to making left child as the right child and vice versa.
1 <= size of tree <= 100000
First and only argument is the head of the tree A.
Return the head of the inverted tree.
Input 1:
1 / \ 2 3
Input 2:
1 / \ 2 3 / \ / \ 4 5 6 7
Output 1:
1 / \ 3 2
Output 2:
1 / \ 3 2 / \ / \ 7 6 5 4
Explanation 1:
Tree has been inverted.
Explanation 2:
Tree has been inverted.
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 question? Checkout Sample Codes for more details.