mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-11 20:08:04 +00:00
Saved tree height challenge solution so it can be reused as a component to other related challenges.
This commit is contained in:
5
graphs_trees/tree_height/height.py
Normal file
5
graphs_trees/tree_height/height.py
Normal file
@@ -0,0 +1,5 @@
|
||||
def height(node):
|
||||
if node is None:
|
||||
return 0
|
||||
return 1 + max(height(node.left),
|
||||
height(node.right))
|
||||
Reference in New Issue
Block a user