Given a binary tree, find its height.
Input: 1 / \ 2 3 Output: 2
Input: 2 \ 1 / 3 Output: 3
You don't need to read input or print anything. Your task is to complete the function height() that takes root Node of the Tree as input and returns the Height of the Tree. If the Tree is empty, return 0.
Expected Time Complexity: O(N).
Expected Auxiliary Space: O(1).
1 <= Number of nodes <= 105
1 <= Data of a node <= 105
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.