Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

My solutions to Leetcode

这是我的 Leetcode 算法题解代码仓。一边练习一边学习,刷题同时记录笔记。使用 JS 语言。

有两种视图:

  1. 按题目序号顺序
  2. 按题目分类

如果对代码仓有任何问题,欢迎联系我:)

按序号

Problems 1-100

ID Problem 中文地址 JS 解题笔记 核心思想 难度
1 two-sum 1. 两数之和 main.js README.md 对撞指针/查找表 easy
3 longest-substring-without-repeating-characters 3. 无重复字符的最长子串 main.ts README.md 双指针维护滑动窗口 medium
11 container-with-most-water 11. 盛最多水的容器 main.ts README.md 双指针 medium
15 3sum 15. 三数之和 main.js README.md map 映射 medium
16 3sum-closest 16. 最接近的三数之和 main.js README.md 排序+双指针 medium
18 4sum 18.四数之和 main.js README.md 排序+双指针 medium
19 remove-nth-node-from-end-of-list 19. 删除链表的倒数第 N 个结点 main.js README.md 链表 medium
20 valid-parentheses 20. 有效的括号 main.js README.md easy
23 merge-k-sorted-lists 23. 合并 K 个升序链表 hard
24 swap-nodes-in-pairs 24. 两两交换链表中的节点 main.ts README.md 链表 medium
26 remove-duplicates-from-sorted-array 26. 删除有序数组中的重复项 main.js README.md 双指针 easy
27 remove-element 27.移除元素 main.ts README.md 双指针 easy
43 multiply-strings 43. 字符串相乘
49 group-anagrams 49. 字母异位词分组 main.js README.md 排序+双指针 medium
70 climbing-stairs 70. 爬楼梯 main.js README.md 动态规划 easy
75 sort-colors 75. 颜色分类 main.ts README.md 计数排序/三路快排 partition medium
76 minimum-window-substring 76. 最小覆盖子串 main.ts README.md 双指针+map hard
80 remove-duplicates-from-sorted-array-ii 80. 删除有序数组中的重复项 II main.ts README.md 双指针 medium
88 merge-sorted-array 88. 合并两个有序数组 main.ts README.md 双指针、数组归并 easy
92 reverse-linked-list-ii 92. 反转链表 II main.js README.md 链表 medium
94 binary-tree-inorder-traversal 94. 二叉树的中序遍历 main.ts README.md 二叉树 easy
98 validate-binary-search-tree 98. 验证二叉搜索树 main.js README.md 递归判断 medium

Problems 101-200

ID Problem 中文地址 JS 解题笔记 核心思想 难度
102 binary-tree-level-order-traversal 102. 二叉树的层序遍历 main.ts README.md BFS medium
103 binary-tree-zigzag-level-order-traversal 103. 二叉树的锯齿形层序遍历 main.ts README.md BFS medium
125 valid-palindrome 125. 验证回文串 main.ts README.md 对撞指针 easy
144 binary-tree-preorder-traversal 144. 二叉树的前序遍历 main.js README.md 迭代 medium
167 two-sum-ii-input-array-is-sorted 167. 两数之和 II - 输入有序数组 main.ts README.md 二分搜索/对撞指针 easy
192 word-frequency 192. 统计词频 main.ts README.md 哈希表计数、Shell medium
198 house-robber 198. 打家劫舍 main.js README.md 动态规划 medium

Problems 201-300

ID Problem 中文地址 JS 解题笔记 核心思想 难度
202 two-sum 202. 快乐数 main1.js README.md 哈希表 easy
203 remove-linked-list-elements 203. 移除链表元素 main.js README.md 链表 easy
205 isomorphic-strings 205. 同构字符串 main.js README.md map 映射 easy
206 reverse-linked-list 206. 反转链表 main.js README.md 链表 easy
209 minimum-size-subarray-sum 209.长度最小的子数组 main.ts README.md 滑动窗口 medium
215 kth-largest-element-in-an-array 215. 数组中的第 K 个最大元素 main.ts RAEDME.md 暴力解/堆/快排partition medium
219 contains-duplicate-ii 219. 存在重复元素 II main.js README.md set easy
220 contains-duplicate-iii 220. 存在重复元素 III main.java README.md 滑动窗口+treeset medium
235 lowest-common-ancestor-of-a-binary-search-tree 235. 二叉搜索树的最近公共祖先 main.js README.md 递归 easy
242 valid-anagram 242. 有效的字母异位词 main.js README.md 线性比较/哈希 easy
257 binary-tree-paths 257. 二叉树的所有路径 main.js README.md 递归 easy
283 move-zeroes 283.移动零 main.ts README.md 数组 easy
290 word-pattern 290. 单词规律 main.js README.md map 映射 easy

Problems 301-400

ID Problem 中文地址 JS 解题笔记 核心思想 难度
303 range-sum-query-immutable 303. 区域和检索 - 数组不可变 main.ts README.md 数组 easy
307 range-sum-query-mutable 303. 区域和检索 - 数组可修改 main.ts README.md 数组 medium
344 reverse-string 344. 反转字符串 main.ts README.md 对撞指针 easy
345 reverse-vowels-of-a-string 345. 反转字符串中的元音字母 main.ts README.md 对撞指针 easy
347 top-k-frequent-elements 347.前K个高频元素 main.js README.md 堆(优先队列) medium
349 intersection-of-two-arrays 349. 两个数组的交集 main.ts README.md set easy
350 intersection-of-two-arrays-ii 350. 两个数组的交集 II main.ts README.md set easy

Problems 401-500

ID Problem 中文地址 JS 解题笔记 核心思想 难度
415 add-strings 415. 字符串相加 main.js README.md 模拟竖式加法 easy
417 pacific-atlantic-water-flow 417. 太平洋大西洋水流问题 main.js README.md DFS medium
438 find-all-anagrams-in-a-string 438. 找到字符串中所有字母异位词 main.ts README.md 滑动窗口 medium
447 number-of-boomerangs 447. 回旋镖的数量 main.js README.md map medium
451 sort-characters-by-frequency 451.根据字符出现频率排序 main.js README.md map medium
454 4sum-ii 454. 四数相加 II main.js README.md 查找表 map medium

Problems 501-600

ID Problem 中文地址 JS 解题笔记 核心思想 难度
504 base-7 504. 七进制数 main.ts README.md easy
515 find-largest-value-in-each-tree-row 515. 在每个树行中找最大值 main.ts README.md 二叉树 medium
547 number-of-provinces 547. 省份数量 main.ts README.md 并查集、深度优先搜索、图 medium

Problems 601-700

ID Problem 中文地址 JS 解题笔记 核心思想 难度
622 design-circular-queue 622. 设计循环队列 main.ts README.md 二叉树 medium
662 maximum-width-of-binary-tree 662. 二叉树最大宽度 main.ts README.md 二叉树 medium
700 search-in-a-binary-search-tree 700. 二叉搜索树中的搜索 main.ts README.md 二叉搜索树BST easy

Problems 701-800

ID Problem 中文地址 JS 解题笔记 核心思想 难度
804 unique-morse-code-words 804. 唯一摩尔斯密码词 main.ts README.md set easy

Problems 801-900

ID Problem 中文地址 JS 解题笔记 核心思想 难度

Problems 901-1000

ID Problem 中文地址 JS 解题笔记 核心思想 难度
912 sort-an-array 912. 排序数组 main.ts README.md 排序 medium
933 number-of-recent-calls 933. 最近的请求次数 mains.js README.md 队列模拟 easy

Problems 1500-1600

ID Problem 中文地址 JS 解题笔记 核心思想 难度
1584 min-cost-to-connect-all-points 1584. 连接所有点的最小费用 main.ts README.md 最小生成树、并查集、图 medium

Problems 3400-3500

ID Problem 中文地址 JS 解题笔记 核心思想 难度
3461 check-if-digits-are-equal-in-string-after-operations-i 3461. 判断操作后字符串中的数字是否相等 I mains.ts README.md 压缩模拟 easy

LCR

ID Problem 中文地址 JS 解题笔记 核心思想 难度
LCR 170 reverse-pairs LCR 170. 交易逆序对的总数 main.ts README.md 归并排序、分治、逆序对 hard

按分类

数组

ID Problem 中文地址 JS 解题笔记 核心思想 难度
303 range-sum-query-immutable 303. 区域和检索 - 数组不可变 main.ts README.md 数组 easy

对撞指针

ID Problem 中文地址 JS 解题笔记 核心思想 难度
1 two-sum 1. 两数之和 main.js README.md 对撞指针/查找表 easy
125 valid-palindrome 125. 验证回文串 main.ts README.md 对撞指针 easy
167 two-sum-ii-input-array-is-sorted 167. 两数之和 II - 输入有序数组 main.ts README.md 二分搜索/对撞指针 easy
344 reverse-string 344. 反转字符串 main.ts README.md 对撞指针
345 reverse-vowels-of-a-string 345. 反转字符串中的元音字母 main.ts README.md 对撞指针

查找表

ID Problem 中文地址 JS 解题笔记 核心思想 难度
1 two-sum 1. 两数之和 main.js README.md 对撞指针/查找表 easy
454 4sum-ii 454. 四数相加 II main.js README.md 查找表 map medium

双指针

ID Problem 中文地址 JS 解题笔记 核心思想 难度
3 longest-substring-without-repeating-characters 3. 无重复字符的最长子串 main.js README.md 双指针维护滑动窗口 medium
11 container-with-most-water 11. 盛最多水的容器 main.ts README.md 双指针 medium
16 3sum-closest 16. 最接近的三数之和 main.js README.md 排序+双指针 medium
18 4sum 18.四数之和 main.js README.md 排序+双指针 medium
26 remove-duplicates-from-sorted-array 26. 删除有序数组中的重复项 main.js README.md 双指针 easy
27 remove-element 27.移除元素 main.ts README.md 双指针 easy
49 group-anagrams 49. 字母异位词分组 main.js README.md 排序+双指针 medium
80 remove-duplicates-from-sorted-array-ii 80. 删除有序数组中的重复项 II main.ts README.md 双指针 medium
88 merge-sorted-array 88. 合并两个有序数组 main.ts README.md 双指针、数组归并 easy

滑动窗口

ID Problem 中文地址 JS 解题笔记 核心思想 难度
3 longest-substring-without-repeating-characters 3. 无重复字符的最长子串 main.ts README.md 双指针维护滑动窗口 medium
76 minimum-window-substring 76. 最小覆盖子串 main.ts README.md 滑动窗口 hard
209 minimum-size-subarray-sum 209.长度最小的子数组 main.ts README.md 滑动窗口 medium
220 contains-duplicate-iii 220. 存在重复元素 III main.java README.md 滑动窗口+treeset medium
438 find-all-anagrams-in-a-string 438. 找到字符串中所有字母异位词 main.ts README.md 滑动窗口 medium

map 映射

ID Problem 中文地址 JS 解题笔记 核心思想 难度
15 3sum 15. 三数之和 main.js README.md map 映射 medium
76 minimum-window-substring 76. 最小覆盖子串 main.js README.md 滑动窗口 hard
205 isomorphic-strings 205. 同构字符串 main.js README.md map 映射 easy
290 word-pattern 290. 单词规律 main.js README.md map 映射 easy
447 number-of-boomerangs 447. 回旋镖的数量 main.js README.md map medium
451 sort-characters-by-frequency 451.根据字符出现频率排序 main.js README.md map medium
454 4sum-ii 454. 四数相加 II main.js README.md 查找表 map medium

Set

ID Problem 中文地址 JS 解题笔记 核心思想 难度
804 unique-morse-code-words 804. 唯一摩尔斯密码词 main.ts README.md set easy

排序

ID Problem 中文地址 JS 解题笔记 核心思想 难度
16 3sum-closest 16. 最接近的三数之和 main.js README.md 排序+双指针 medium
18 4sum 18.四数之和 main.js README.md 排序+双指针 medium
49 group-anagrams 49. 字母异位词分组 main.js README.md 排序+双指针 medium
75 sort-colors 75. 颜色分类 main.ts README.md 计数排序/三路快排 partition medium
LCR 170 reverse-pairs LCR 170. 交易逆序对的总数 main.ts README.md 归并排序、分治、逆序对 hard

链表

ID Problem 中文地址 JS 解题笔记 核心思想 难度
19 remove-nth-node-from-end-of-list 19. 删除链表的倒数第 N 个结点 main.js README.md 链表 medium
24 swap-nodes-in-pairs 24. 两两交换链表中的节点 main.js README.md 链表 medium
92 reverse-linked-list-ii 92. 反转链表 II main.js README.md 链表 medium
203 remove-linked-list-elements 203. 移除链表元素 main.js README.md 链表 easy
206 reverse-linked-list 206. 反转链表 main.js README.md 链表 easy

ID Problem 中文地址 JS 解题笔记 核心思想 难度
20 valid-parentheses 20. 有效的括号 main.js README.md easy
504 base-7 504. 七进制数 main.ts README.md easy

ID Problem 中文地址 JS 解题笔记 核心思想 难度
94 binary-tree-inorder-traversal 94. 二叉树的中序遍历 main.ts README.md 二叉树 easy
102 binary-tree-level-order-traversal 102. 二叉树的层序遍历 main.ts README.md BFS medium
103 binary-tree-zigzag-level-order-traversal 103. 二叉树的锯齿形层序遍历 main.ts README.md BFS medium
307 range-sum-query-mutable 303. 区域和检索 - 数组可修改 main.ts README.md 线段树 medium
515 find-largest-value-in-each-tree-row 515. 在每个树行中找最大值 main.ts README.md 二叉树 medium
662 maximum-width-of-binary-tree 662. 二叉树最大宽度 main.ts README.md 二叉树 medium
700 search-in-a-binary-search-tree 700. 二叉搜索树中的搜索 main.ts README.md 二叉搜索树BST easy

ID Problem 中文地址 JS 解题笔记 核心思想 难度
1584 min-cost-to-connect-all-points 1584. 连接所有点的最小费用 main.ts README.md 最小生成树、并查集、图 medium

并查集

ID Problem 中文地址 JS 解题笔记 核心思想 难度
547 number-of-provinces 547. 省份数量 main.ts README.md 并查集、深度优先搜索、图 medium

动态规划

ID Problem 中文地址 JS 解题笔记 核心思想 难度
70 climbing-stairs 70. 爬楼梯 main.js README.md 动态规划 easy
198 house-robber 198. 打家劫舍 main.js README.md 动态规划 medium

partition

ID Problem 中文地址 JS 解题笔记 核心思想 难度
75 sort-colors 75. 颜色分类 main.ts README.md 计数排序/三路快排 partition medium

递归判断

ID Problem 中文地址 JS 解题笔记 核心思想 难度
98 validate-binary-search-tree 98. 验证二叉搜索树 main.js README.md 递归判断 medium

BFS

ID Problem 中文地址 JS 解题笔记 核心思想 难度
102 binary-tree-level-order-traversal 102. 二叉树的层序遍历 main.ts README.md BFS medium
103 binary-tree-zigzag-level-order-traversal 103. 二叉树的锯齿形层序遍历 main.ts README.md BFS medium

迭代

ID Problem 中文地址 JS 解题笔记 核心思想 难度
144 binary-tree-preorder-traversal 144. 二叉树的前序遍历 main.js README.md 迭代 medium

二分搜索

ID Problem 中文地址 JS 解题笔记 核心思想 难度
167 two-sum-ii-input-array-is-sorted 167. 两数之和 II - 输入有序数组 main.js README.md 二分搜索/对撞指针 easy

哈希表

ID Problem 中文地址 JS 解题笔记 核心思想 难度
192 word-frequency 192. 统计词频 main.ts README.md 哈希表计数、Shell medium
202 two-sum 202. 快乐数 main1.js README.md 哈希表 easy
242 valid-anagram 242. 有效的字母异位词 main.js README.md 线性比较/哈希 easy

ID Problem 中文地址 JS 解题笔记 核心思想 难度
215 kth-largest-element-in-an-array 215. 数组中的第 K 个最大元素 main.ts RAEDME.md 暴力解/堆/快排partition medium

快速选择

ID Problem 中文地址 JS 解题笔记 核心思想 难度
215 kth-largest-element-in-an-array 215. 数组中的第 K 个最大元素 main.js RAEDME.md 暴力解/堆/快速选择 medium

set

ID Problem 中文地址 JS 解题笔记 核心思想 难度
219 contains-duplicate-ii 219. 存在重复元素 II main.js README.md set easy
349 intersection-of-two-arrays 349. 两个数组的交集 main.ts README.md set easy
350 intersection-of-two-arrays-ii 350. 两个数组的交集 II main.ts README.md set easy

TreeSet

ID Problem 中文地址 JS 解题笔记 核心思想 难度
220 contains-duplicate-iii 220. 存在重复元素 III main.java README.md 滑动窗口+treeset medium

递归

ID Problem 中文地址 JS 解题笔记 核心思想 难度
235 lowest-common-ancestor-of-a-binary-search-tree 235. 二叉搜索树的最近公共祖先 main.js README.md 递归 easy
257 binary-tree-paths 257. 二叉树的所有路径 main.js README.md 递归 easy

线性比较

ID Problem 中文地址 JS 解题笔记 核心思想 难度
242 valid-anagram 242. 有效的字母异位词 main.js README.md 线性比较/哈希 easy

数组

ID Problem 中文地址 JS 解题笔记 核心思想 难度
283 move-zeroes 283.移动零 main.ts README.md 数组、双指针 easy
3461 check-if-digits-are-equal-in-string-after-operations-i 3461. 判断操作后字符串中的数字是否相等 I mains.ts README.md 压缩模拟 easy

数学运算

ID Problem 中文地址 JS 解题笔记 核心思想 难度
415 add-strings 415. 字符串相加 main.js README.md 模拟竖式加法 easy

DFS

ID Problem 中文地址 JS 解题笔记 核心思想 难度
417 pacific-atlantic-water-flow 417. 太平洋大西洋水流问题 main.js README.md DFS medium

队列

ID Problem 中文地址 JS 解题笔记 核心思想 难度
622 design-circular-queue 622. 设计循环队列 main.ts README.md 循环队列 medium
933 number-of-recent-calls 933. 最近的请求次数 mains.js README.md 队列模拟 easy

ID Problem 中文地址 JS 解题笔记 核心思想 难度
347 top-k-frequent-elements 347.前K个高频元素 main.js README.md 堆(优先队列) medium

About

(持续更新中) 我的Leetcode解答。所有的问题都支持JS语言。包含代码解答+思路整理。还有目录索引便于查看

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages