543.二叉树的直径
作者:互联网
var diameterOfBinaryTree = function (root) { let Max = 0; const depth = (root) => { if (!root) return 0; let l = depth(root.left); let r = depth(root.right); if (l + r > Max) { Max = l + r; } return Math.max(l, r) + 1; }; depth(root); return Max; };
标签:return,Max,543,depth,let,二叉树,直径,root 来源: https://www.cnblogs.com/guodandan/p/15065503.html