You are viewing a single comment's thread. Return to all comments →
NO. they haven't mentioned that in the problem.
but in editorial they return -1 for root == Null because:
return 1 + max(height(root.left), height(root.right))
because they return 1 + max(root.left+root.right) now if root.left or root.right were null then max(blah blah) will return -1 and together they would return 0 as height of that root without left or right subtree..
1 + max(root.left+root.right)
Yes, you are right;
orelse, it return the height+1
Seriously, who solved the problem without looking reading discussion?