标签:ini solution math 面试题 ble leetcode max node def
链接:https://leetcode-cn.com/problems/er-cha-shu-de-shen-du-lcof/
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
class Solution {
public int maxDepth(TreeNode root) {
int cnt = 0;
if (root == null) return 0;
return Math.max(maxDepth(root.left), maxDepth(root.right)) + 1;
}
}
标签:ini solution math 面试题 ble leetcode max node def
原文地址:https://www.cnblogs.com/clown9804/p/12455093.html