主要针对二叉树
定义
链式存储:
class TreeNode {
constructor(val, left, right) {
this.val = val === undefined ? 0 : val
this.left = left === undefined ? null : left
this.right = right === undefined ? null : right
}
}
leetcode:
基本递归相关:
深度相关:
路径相关:
有条件的递归:
构造: