<filename>algorithms/104.Maximum-Depth-of-Binary-Tree/Python/solution_1.py
"""
https://leetcode.com/problems/maximum-depth-of-binary-tree/
"""
# Definition for a binary tree node.
class TreeNode:
    def __init__(self, val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right


class Solution:
    def maxDepth(self, root: TreeNode) -> int:
        self.maxDepth = 0
        self.walk(root, 0)
        return self.maxDepth

    def walk(self, root: TreeNode, depth: int) -> None:
        if root == None:
            self.maxDepth = max(self.maxDepth, depth)
            return
        self.walk(root.left, depth + 1)
        self.walk(root.right, depth + 1)

<filename>algorithms/104.Maximum-Depth-of-Binary-Tree/Python/solution_1.py
"""
https://leetcode.com/problems/maximum-depth-of-binary-tree/
"""
# Definition for a binary tree node.
class TreeNode:
    def __init__(self, val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right


class Solution:
    def maxDepth(self, root: TreeNode) -> int:
        self.maxDepth = 0
        self.walk(root, 0)
        return self.maxDepth

    def walk(self, root: TreeNode, depth: int) -> None:
        if root == None:
            self.maxDepth = max(self.maxDepth, depth)
            return
        self.walk(root.left, depth + 1)
        self.walk(root.right, depth + 1)

https://leetcode.com/problems/maximum-depth-of-binary-tree/ # Definition for a binary tree node.