Given a Binary Tree, check if all leaves are at same level or not.
12 / \ 5 7 / \ 3 1 Leaves are at same level 12 / \ 5 7 / 3 Leaves are Not at same level 12 / 5 / \ 3 9 / / 1 2 Leaves are at same level
The task is to complete the method that takes one argument, root of Binary Tree and returns 1 if all leaves are at same level else returns 0
Output for each test case will be 0 if all leaves are not at same level else it will 1.
1 <=T<= 30
1 <= Number of nodes<= 100
1 <= Data of a node<= 1000
Example(To be used only for expected output):
1 2 R 1 3 L
10 20 L 10 30 R 20 40 L 20 60 R
Note:The Input/Ouput format and Example given are used for system's internal purpose, and should be used by a user for Expected Output only. As it is a function problem, hence a user should not read any input from stdin/console. The task is to complete the function specified, and not to write the full code.
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.