Last active
October 24, 2017 07:09
-
-
Save evidanary/2eeb325aabb4900a2d634941f826348a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# returns depth and node at the maximum depth | |
def max_depth(node) | |
return [0, node] if node.nil? | |
left = max_depth(node.left) + 1 | |
right = max_depth(node.right) + 1 | |
left[0] > right[0] ? left : right | |
ends |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment