天天看點

LeetCode基礎--二叉樹-求最大高度

題目描述:

求二叉樹的最大高度。

代碼實作:

public class Solution {
    public int maxDepth(TreeNode root) {
        if(root == null) 
        {
            return ;
        }
        int left = , right = ;
        left = maxDepth(root.left);
        right = maxDepth(root.right);
        return Math.max(left, right) + ;
    }
}