摘要:
//创建一个Person类 class Person { //构造器方法 constructor(name,age){ //构造器中的this是谁?—— 类的实例对象 this.name = name this.age = age } //一般方法 speak(){ //speak方法放在了哪里?— 阅读全文
摘要:
var diameterOfBinaryTree = function (root) { let Max = 0; const depth = (root) => { if (!root) return 0; let l = depth(root.left); let r = depth(root. 阅读全文
摘要:
var mergeTrees = function (root1, root2) { if (root1 null && root2 null) return null; if (root1 null && root2 !== null) return root2; if (root1 !== nu 阅读全文
摘要:
var invertTree = function (root) { if (!root) return null; let p = root.left; root.left = root.right; root.right = p; invertTree(root.left); invertTre 阅读全文
摘要:
var hasPathSum = function (root, targetSum) { if (!root) return false; let flag = false; const dfs = (root, sum) => { if (!root) return; if (!root.lef 阅读全文
摘要:
var maxDepth = function (root) { if (!root) return 0; let res = 0; const dfs = (root, l) => { if (!root) return; if (!root.left && !root.right) { res 阅读全文