Created
October 9, 2016 08:46
-
-
Save tmosest/6b0ca8cce797a741cff991f1eb7a3ae3 to your computer and use it in GitHub Desktop.
Hackerrank: Day 22: Binary Search Tress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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