摘要: //创建一个Person类 class Person { //构造器方法 constructor(name,age){ //构造器中的this是谁?—— 类的实例对象 this.name = name this.age = age } //一般方法 speak(){ //speak方法放在了哪里?— 阅读全文
posted @ 2021-09-12 11:47 jlin7 阅读(33) 评论(0) 推荐(0)
摘要: var isValidBST = function (root) { const isValid = (root, lower, upper) => { if (root null) return true; if (root.val <= lower || root.val >= upper) r 阅读全文
posted @ 2021-07-28 11:10 jlin7 阅读(19) 评论(0) 推荐(0)
摘要: 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)
摘要: 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 阅读(26) 评论(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 阅读(28) 评论(0) 推荐(0)
点击右上角即可分享
微信分享提示