Skip to content

Commit 59e5728

Browse files
committed
leetcode算法题推荐
1 parent b1f22a0 commit 59e5728

File tree

2 files changed

+158
-0
lines changed

2 files changed

+158
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# 经典算法思想介绍
2+
3+
## 贪心算法
4+
5+
### 算法思想
6+
7+
贪心的本质是选择每一阶段的局部最优,从而达到全局最优。
8+
9+
### 一般解题步骤
10+
11+
- 将问题分解为若干个子问题
12+
- 找出适合的贪心策略
13+
- 求解每一个子问题的最优解
14+
- 将局部最优解堆叠成全局最优解
15+
16+
### LeetCode
17+
18+
455.分发饼干:https://leetcode.cn/problems/assign-cookies/
19+
20+
121.买卖股票的最佳时机:https://leetcode.cn/problems/best-time-to-buy-and-sell-stock/
21+
22+
122.买卖股票的最佳时机II:https://leetcode.cn/problems/best-time-to-buy-and-sell-stock-ii/
23+
24+
55.跳跃游戏:https://leetcode.cn/problems/jump-game/
25+
26+
45.跳跃游戏II:https://leetcode.cn/problems/jump-game-ii/
27+
28+
## 动态规划
29+
30+
### 算法思想
31+
32+
动态规划中每一个状态一定是由上一个状态推导出来的,这一点就区分于贪心,贪心没有状态推导,而是从局部直接选最优的。
33+
34+
经典题目:01背包、完全背包
35+
36+
### 一般解题步骤
37+
38+
- 确定dp数组(dp table)以及下标的含义
39+
- 确定递推公式
40+
- dp数组如何初始化
41+
- 确定遍历顺序
42+
- 举例推导dp数组
43+
44+
### LeetCode
45+
46+
509.斐波那契数:https://leetcode.cn/problems/fibonacci-number/
47+
48+
746.使用最小花费爬楼梯:https://leetcode.cn/problems/min-cost-climbing-stairs/
49+
50+
416.分割等和子集:https://leetcode.cn/problems/partition-equal-subset-sum/
51+
52+
518.零钱兑换:https://leetcode.cn/problems/coin-change-ii/
53+
54+
647.回文子串:https://leetcode.cn/problems/palindromic-substrings/
55+
56+
516.最长回文子序列:https://leetcode.cn/problems/longest-palindromic-subsequence/
57+
58+
## 回溯算法
59+
60+
### 算法思想
61+
62+
回溯算法实际上一个类似枚举的搜索尝试过程,主要是在搜索尝试过程中寻找问题的解,当发现已不满足求解条
63+
64+
件时,就“回溯”返回,尝试别的路径。其本质就是穷举。
65+
66+
经典题目:8皇后
67+
68+
### 一般解题步骤
69+
70+
- 针对所给问题,定义问题的解空间,它至少包含问题的一个(最优)解。
71+
- 确定易于搜索的解空间结构,使得能用回溯法方便地搜索整个解空间 。
72+
- 以深度优先的方式搜索解空间,并且在搜索过程中用剪枝函数避免无效搜索。
73+
74+
### leetcode
75+
76+
77.组合:https://leetcode.cn/problems/combinations/
77+
78+
39.组合总和:https://leetcode.cn/problems/combination-sum/
79+
80+
40.组合总和II:https://leetcode.cn/problems/combination-sum-ii/
81+
82+
78.子集:https://leetcode.cn/problems/subsets/
83+
84+
90.子集II:https://leetcode.cn/problems/subsets-ii/
85+
86+
51.N皇后:https://leetcode.cn/problems/n-queens/
87+
88+
## 分治算法
89+
90+
### 算法思想
91+
92+
将一个规模为N的问题分解为K个规模较小的子问题,这些子问题相互独立且与原问题性质相同。求出子问题的解,就可得到原问题的解。
93+
94+
经典题目:二分查找、汉诺塔问题
95+
96+
### 一般解题步骤
97+
98+
- 将原问题分解为若干个规模较小,相互独立,与原问题形式相同的子问题;
99+
- 若子问题规模较小而容易被解决则直接解,否则递归地解各个子问题
100+
- 将各个子问题的解合并为原问题的解。
101+
102+
### LeetCode
103+
104+
108.将有序数组转换成二叉搜索数:https://leetcode.cn/problems/convert-sorted-array-to-binary-search-tree/
105+
106+
148.排序列表:https://leetcode.cn/problems/sort-list/
107+
108+
23.合并k个升序链表:https://leetcode.cn/problems/merge-k-sorted-lists/
109+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# 数组
2+
3+
704.二分查找:https://leetcode.cn/problems/binary-search/
4+
5+
80.删除有序数组中的重复项II:https://leetcode.cn/problems/remove-duplicates-from-sorted-array-ii
6+
7+
977.有序数组的平方:https://leetcode.cn/problems/squares-of-a-sorted-array/
8+
9+
# 链表
10+
11+
707.设计链表:https://leetcode.cn/problems/design-linked-list/
12+
13+
206.反转链表:https://leetcode.cn/problems/reverse-linked-list/
14+
15+
92.反转链表II:https://leetcode.cn/problems/reverse-linked-list-ii/
16+
17+
61.旋转链表:https://leetcode.cn/problems/rotate-list/
18+
19+
# 栈与队列
20+
21+
232.用栈实现队列:https://leetcode.cn/problems/implement-queue-using-stacks/
22+
23+
225.用队列实现栈:https://leetcode.cn/problems/implement-stack-using-queues/
24+
25+
347.前K个高频元素:https://leetcode.cn/problems/top-k-frequent-elements/
26+
27+
239.滑动窗口最大值:https://leetcode.cn/problems/sliding-window-maximum/
28+
29+
# 二叉树
30+
31+
105.从前序与中序遍历构造二叉树:https://leetcode.cn/problems/construct-binary-tree-from-preorder-and-inorder-traversal/
32+
33+
117.填充每个节点的下一个右侧节点指针II:https://leetcode.cn/problems/populating-next-right-pointers-in-each-node-ii
34+
35+
236.二叉树的最近公共祖先:https://leetcode.cn/problems/lowest-common-ancestor-of-a-binary-tree/
36+
37+
129.求根节点到叶节点数字之和:https://leetcode.cn/problems/sum-root-to-leaf-numbers/
38+
39+
102.二叉树的层序遍历:https://leetcode.cn/problems/binary-tree-level-order-traversal/
40+
41+
530.二叉搜索树的最小绝对差:https://leetcode.cn/problems/minimum-absolute-difference-in-bst/
42+
43+
#
44+
45+
200.岛屿数量:https://leetcode.cn/problems/number-of-islands/
46+
47+
207.课程表:https://leetcode.cn/problems/course-schedule/
48+
49+
210.课程表II:https://leetcode.cn/problems/course-schedule-ii/

0 commit comments

Comments
 (0)