Created
February 1, 2016 01:52
-
-
Save sb8244/227ca745c730f1bcc9e6 to your computer and use it in GitHub Desktop.
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
def solution(t) | |
traverse_height(t, 0) | |
end | |
def traverse_height(t, current_height) | |
return current_height - 1 if t.nil? | |
left_height = traverse_height(t.l, current_height+1) | |
right_height = traverse_height(t.r, current_height+1) | |
[left_height, right_height].max | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment