摘要: var diameterOfBinaryTree = function (root) { let Max = 0; const depth = (root) => { if (!root) return 0; let l = depth(root.left); let r = depth(root. 阅读全文
posted @ 2021-07-27 13:48 jlin7 阅读(29) 评论(0) 推荐(0)
摘要: var mergeTrees = function (root1, root2) { if (root1 null && root2 null) return null; if (root1 null && root2 !== null) return root2; if (root1 !== nu 阅读全文
posted @ 2021-07-27 12:47 jlin7 阅读(30) 评论(0) 推荐(0)
摘要: var invertTree = function (root) { if (!root) return null; let p = root.left; root.left = root.right; root.right = p; invertTree(root.left); invertTre 阅读全文
posted @ 2021-07-27 12:32 jlin7 阅读(16) 评论(0) 推荐(0)
摘要: var lowestCommonAncestor = function (root, p, q) { if (root null || root p || root q) { return root; } let p1 = lowestCommonAncestor(root.left, p, q); 阅读全文
posted @ 2021-07-27 10:20 jlin7 阅读(13) 评论(0) 推荐(0)