LeetCode – Maximum Depth of Binary Tree (Java)

Given a binary tree, find its maximum depth.

The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.

Java Solution

public int maxDepth(TreeNode root) {
        return 0;
    int leftDepth = maxDepth(root.left);
    int rightDepth = maxDepth(root.right);
    int bigger = Math.max(leftDepth, rightDepth);
    return bigger+1;
Category >> Algorithms  
If you want someone to read your code, please put the code inside <pre><code> and </code></pre> tags. For example:
String foo = "bar";