Skip to content

Instantly share code, notes, and snippets.

@tmosest
Created October 9, 2016 08:46
Show Gist options
  • Save tmosest/6b0ca8cce797a741cff991f1eb7a3ae3 to your computer and use it in GitHub Desktop.
Save tmosest/6b0ca8cce797a741cff991f1eb7a3ae3 to your computer and use it in GitHub Desktop.
Hackerrank: Day 22: Binary Search Tress
public static int getHeight(Node root) {
int heightLeft = 0;
int heightRight = 0;
if (root.left != null) {
heightLeft = getHeight(root.left) + 1;
}
if (root.right != null) {
heightRight = getHeight(root.right) + 1;
}
return (heightLeft > heightRight ? heightLeft : heightRight);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment