mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-05-25 01:41:20 -04:00
add some fun tree playing
This commit is contained in:
parent
48720ada4d
commit
bb72bab679
6 changed files with 209 additions and 0 deletions
6
trees_and_graphs/find_max_depth_tree.py
Normal file
6
trees_and_graphs/find_max_depth_tree.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
def max_depth(root: Optional[TreeNode]) -> int:
|
||||
|
||||
if root is None:
|
||||
return 0
|
||||
|
||||
return max(max_depth(root.left) + 1, max_depth(root.right) + 1)
|
Loading…
Add table
Add a link
Reference in a new issue