// https://leetcode-cn.com/problems/maximum-depth-of-binary-tree/
var maxDepth = function(root) {
if (!root) return 0;
const leftDepth = maxDepth(root.left);
const rightDepth = maxDepth(root.right);
return leftDepth > rightDepth ? leftDepth + 1 : rightDepth + 1;
};
网友评论