LC刷题
JavaScript刷题笔记
「已注销」
漫漫前端路,就好比西游里面的取经之路,无外乎需要经历九九之难、消除各种妖魔鬼怪才能有所收获。
展开
-
LC-翻转二叉树(JavaScript实现)
/* * @lc app=leetcode.cn id=226 lang=javascript * * [226] 翻转二叉树 */// @lc code=start/** * Definition for a binary tree node. * function TreeNode(val, left, right) { * this.val = (val===undefined ? 0 : val) * this.left = (left===undefined原创 2022-02-10 08:47:44 · 727 阅读 · 2 评论 -
LC-路径总和(JavaScript实现)
/* * @lc app=leetcode.cn id=112 lang=javascript * * [112] 路径总和 */// @lc code=start/** * Definition for a binary tree node. * function TreeNode(val, left, right) { * this.val = (val===undefined ? 0 : val) * this.left = (left===undefined ?原创 2022-02-08 12:15:50 · 457 阅读 · 0 评论 -
LC-平衡二叉树(JavaScript实现)
/* * @lc app=leetcode.cn id=110 lang=javascript * * [110] 平衡二叉树 */// @lc code=start/** * Definition for a binary tree node. * function TreeNode(val, left, right) { * this.val = (val===undefined ? 0 : val) * this.left = (left===undefined原创 2022-02-06 10:55:05 · 588 阅读 · 0 评论 -
LC-恢复二叉搜索树(JavaScript实现)
/* * @lc app=leetcode.cn id=99 lang=javascript * * [99] 恢复二叉搜索树 */// @lc code=start/** * Definition for a binary tree node. * function TreeNode(val, left, right) { * this.val = (val===undefined ? 0 : val) * this.left = (left===undefined原创 2022-02-05 15:26:07 · 981 阅读 · 0 评论 -
LC-二叉树的中序遍历(JavaScript实现)
/* * @lc app=leetcode.cn id=94 lang=javascript * * [94] 二叉树的中序遍历 */// @lc code=start/** * Definition for a binary tree node. * function TreeNode(val, left, right) { * this.val = (val===undefined ? 0 : val) * this.left = (left===undefined原创 2022-02-05 14:47:27 · 93 阅读 · 0 评论 -
LC-验证二叉搜索树(JavaScript实现)
/* * @lc app=leetcode.cn id=98 lang=javascript * * [98] 验证二叉搜索树 */// @lc code=start/** * Definition for a binary tree node. * function TreeNode(val, left, right) { * this.val = (val===undefined ? 0 : val) * this.left = (left===undefined原创 2022-02-05 14:26:42 · 523 阅读 · 0 评论 -
LC-不同的二叉搜索树 (JavaScript实现)
/* * @lc app=leetcode.cn id=96 lang=typescript * * [96] 不同的二叉搜索树 */// @lc code=startfunction numTrees(n: number): number { let ans:number =1 ; for(let i:number=1;i<=n;i++) ans=ans*2*((i-1)*2+1)/((i-1)+2) return ans;};// @lc c原创 2022-02-04 18:44:13 · 290 阅读 · 0 评论 -
LC-二叉树的最小深度(JavaScript实现)
/** * Definition for a binary tree node. * function TreeNode(val, left, right) { * this.val = (val===undefined ? 0 : val) * this.left = (left===undefined ? null : left) * this.right = (right===undefined ? null : right) * } *//** * @par原创 2022-02-01 13:20:19 · 869 阅读 · 0 评论 -
LC-对称二叉树(JavaScript实现)
/** * Definition for a binary tree node. * function TreeNode(val, left, right) { * this.val = (val===undefined ? 0 : val) * this.left = (left===undefined ? null : left) * this.right = (right===undefined ? null : right) * } *//** * @par原创 2022-01-27 20:53:04 · 1064 阅读 · 0 评论 -
LC- 从前序与中序遍历序列构造二叉树(JavaScript实现)
/* * @lc app=leetcode.cn id=105 lang=javascript * * [105] 从前序与中序遍历序列构造二叉树 */// @lc code=start/** * Definition for a binary tree node. * function TreeNode(val, left, right) { * this.val = (val===undefined ? 0 : val) * this.left = (left===原创 2022-01-25 21:06:32 · 790 阅读 · 0 评论 -
LC-二叉树的层序遍历(JavaScript实现)
/** * Definition for a binary tree node. * function TreeNode(val, left, right) { * this.val = (val===undefined ? 0 : val) * this.left = (left===undefined ? null : left) * this.right = (right===undefined ? null : right) * } *//** * @par原创 2022-01-23 23:21:25 · 513 阅读 · 0 评论 -
LC-相同的树(JavaScript实现)
/** * Definition for a binary tree node. * function TreeNode(val, left, right) { * this.val = (val===undefined ? 0 : val) * this.left = (left===undefined ? null : left) * this.right = (right===undefined ? null : right) * } *//** * @par原创 2022-01-23 22:59:09 · 317 阅读 · 0 评论