Timer is Running

Two Mirror Trees
Submissions: 17699   Accuracy:

49.96%

  Difficulty: Easy   Marks: 2
Associated Course(s):   Amazon SDE Test Series

Given a Two Binary Trees, write a function that returns true if one is mirror of other, else returns false.
MirrorTree1            

Input:
First line of input contains the number of test cases T. For each test case, there will be two lines of input which is a string representing the tree as described below: 

  1. The values in the string are in the order of level order traversal of the tree where, numbers denotes node values, and a character “N” denotes NULL child.

  2. For example:

    For the above tree, the string will be: 1 2 3 N N 4 6 N 5 N N 7 N

Output:
The function should return true if the first tree is a mirror of the second.

Your Task:
You don't need to take input. Just complete the function areMirror() that takes root node of two tree as parameter and returns true, if one is the mirror of other
 else returns false.
Expected Time Complexity: O(N).
Expected Auxiliary Space: O(Height of the Tree).


Constraints:
1 <= T <= 100
1 <= Number of nodes<= 10000
-1000 <= Data of a node<= 1000

Example:
Input:

2
1 2 3
1 3 2
10 20 30 40 60
10 20 30 40 60

Output:
1
0

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Amit Khandelwal
Author: kartik


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.