Given the root of a binary tree, return its maximum depth.

A binary tree's maximum depth&nbsp;is the number of nodes along the longest path from the root node down to the farthest leaf node.

&nbsp;
Example 1:

Input: root = [3,9,20,null,null,15,7]
Output: 3


Example 2:

Input: root = [1,null,2]
Output: 2


&nbsp;
Constraints:


	The number of nodes in the tree is in the range [0, 104].
	-100 &lt;= Node.val &lt;= 100


class Solution(object):
    def maxDepth(self, root):
        """
        :type root: TreeNode
        :rtype: int
        """
        result = 0
        depths = []
        self.handler(root, result, depths)
        return max(depths)

    def handler(self, root, result, depths):
        if root:
            result += 1
            self.handler(root.left, result, depths)
            self.handler(root.right, result, depths)
        else:
            depths.append(result)
class Solution {
    public int maxDepth(TreeNode root) {
        // Base Condition
        if(root == null) return 0;
        // Hypothesis
        int left = maxDepth(root.left);
        int right = maxDepth(root.right);
        // Induction
        return Math.max(left, right) + 1;
    }
}
class Solution {
public:
    int maxDepth(TreeNode* root) {
        if(root == NULL) return 0;
        int left = maxDepth(root->left);
        int right = maxDepth(root->right);
        return max(left, right) + 1;
    }
};
var maxDepth = function(root) {
    if(root == null) return 0
    
    let leftDepth = maxDepth(root.left)
    let rightDepth = maxDepth(root.right)
    
    let ans = Math.max(leftDepth,rightDepth) + 1
    
    return ans
};
Maximum Depth of Binary Tree