Find the maximum Height of a Binary Tree

The height of binary tree is the maximum distance from the root to the children

If the binary tree is null or has only one node, then the height is zero.

If the binary tree is null or has only one node, then the height is zero.

The maximum height of below tree is 2

int maxHeight(Node root){ if(root != null){ if(root.left != null || root.right != null){ int l = maxHeight(root.left); int r = maxHeight(root.right); return max(l, r)+1; } } return 0; }