Skip to content

Instantly share code, notes, and snippets.

@ThomasHigginson
Created April 1, 2022 16:02
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 ThomasHigginson/21a143c74d0f74fe79018dd3539758fd to your computer and use it in GitHub Desktop.
Save ThomasHigginson/21a143c74d0f74fe79018dd3539758fd to your computer and use it in GitHub Desktop.
class Solution:
def maxDepth(self, root: Optional[TreeNode]) -> int:
if not root: # Base case
return 0
return 1 + max(self.maxDepth(root.left), self.maxDepth(root.right))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment