We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
// Start of function getHeight
this.getHeight = function(root) {
if (root===null) return -1;
leftheight=this.getHeight(root.left);
rightheight=this.getHeight(root.right);
return Math.max(leftheight,rightheight)+1;
}; // End of function getHeight
Don't understand how the output get 2 with the below input. Any expert can help to shed some light please. Thanks!
9
20
50
35
44
9
15
62
11
13
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 22: Binary Search Trees
You are viewing a single comment's thread. Return to all comments →
Javascript code:
Don't understand how the output get 2 with the below input. Any expert can help to shed some light please. Thanks!
9 20 50 35 44 9 15 62 11 13