摘要:
var lowestCommonAncestor = function (root, p, q) { if (!root) return null; let res = null; const rec = (root) => { if (root.val > p.val && root.val > 阅读全文
posted @ 2021-07-26 19:47
jlin7
阅读(20)
评论(0)
推荐(0)
摘要:
var hasPathSum = function (root, targetSum) { if (!root) return false; let flag = false; const dfs = (root, sum) => { if (!root) return; if (!root.lef 阅读全文
posted @ 2021-07-26 18:36
jlin7
阅读(27)
评论(0)
推荐(0)
摘要:
var minDepth = function (root) { if (!root) return 0; let resArr = []; const dfs = (root, l) => { if (!root) return; if (!root.left && !root.right) { 阅读全文
posted @ 2021-07-26 16:44
jlin7
阅读(25)
评论(0)
推荐(0)
摘要:
var maxDepth = function (root) { if (!root) return 0; let res = 0; const dfs = (root, l) => { if (!root) return; if (!root.left && !root.right) { res 阅读全文
posted @ 2021-07-26 16:38
jlin7
阅读(30)
评论(0)
推荐(0)
摘要:
//dfs实现var levelOrder = function (root) { let result = []; const dfs = (root, l) => { if (!root) return; if (result[l]) { result[l].push(root.val); } 阅读全文
posted @ 2021-07-26 16:29
jlin7
阅读(42)
评论(0)
推荐(0)
摘要:
//1、递归var isSymmetric = function (root) { if (!root) return false; let flag = true; const rec = (left, right) => { if (left null && right null) { retu 阅读全文
posted @ 2021-07-26 15:57
jlin7
阅读(20)
评论(0)
推荐(0)

浙公网安备 33010602011771号