Skip to content

Instantly share code, notes, and snippets.

@sb8244
Created February 1, 2016 01:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sb8244/227ca745c730f1bcc9e6 to your computer and use it in GitHub Desktop.
Save sb8244/227ca745c730f1bcc9e6 to your computer and use it in GitHub Desktop.
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