Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c0488b5

Browse files
Merge pull request #1 from greyireland/master
202008140911
2 parents 6dda558 + 2741c8c commit c0488b5

File tree

9 files changed

+84
-32
lines changed

9 files changed

+84
-32
lines changed

‎README.md

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
![来刷题了](https://img.fuiboom.com/img/title.png)
44

5-
算法模板,最科学的刷题方式,最快速的刷题路径,一个月从入门到 offer,你值得拥有~
5+
算法模板,最科学的刷题方式,最快速的刷题路径,一个月从入门到 offer,你值得拥有 🐶~
66

77
算法模板顾名思义就是刷题的套路模板,掌握了刷题模板之后,刷题也变得好玩起来了~
88

9-
> 此项目是自己找工作时,从 0 开始刷 LeetCode 的心得记录,通过各种刷题文章、专栏、视频等总结了一套自己的刷题模板,仅供参考。
9+
> 此项目是自己找工作时,从 0 开始刷 LeetCode 的心得记录,通过各种刷题文章、专栏、视频等总结了一套自己的刷题模板。
10+
>
11+
> 这个模板主要是介绍了一些通用的刷题模板,以及一些常见问题,如到底要刷多少题,按什么顺序来刷题,如何提高刷题效率等。
1012
1113
## 在线文档
1214

@@ -16,28 +18,28 @@
1618

1719
### 入门篇 🐶
1820

19-
- [go 语言入门](introduction/golang.md)
20-
- [算法快速入门](introduction/quickstart.md)
21+
- [go 语言入门](./introduction/golang.md)
22+
- [算法快速入门](./introduction/quickstart.md)
2123

2224
### 数据结构篇 🐰
2325

24-
- [二叉树](data_structure/binary_tree.md)
25-
- [链表](data_structure/linked_list.md)
26-
- [栈和队列](data_structure/stack_queue.md)
27-
- [二进制](data_structure/binary_op.md)
26+
- [二叉树](./data_structure/binary_tree.md)
27+
- [链表](./data_structure/linked_list.md)
28+
- [栈和队列](./data_structure/stack_queue.md)
29+
- [二进制](./data_structure/binary_op.md)
2830

2931
### 基础算法篇 🐮
3032

31-
- [二分搜索](basic_algorithm/binary_search.md)
32-
- [排序算法](basic_algorithm/sort.md)
33-
- [动态规划](basic_algorithm/dp.md)
33+
- [二分搜索](./basic_algorithm/binary_search.md)
34+
- [排序算法](./basic_algorithm/sort.md)
35+
- [动态规划](./basic_algorithm/dp.md)
3436

3537
### 算法思维 🦁
3638

37-
- [递归思维](advanced_algorithm/recursion.md)
38-
- [滑动窗口思想](advanced_algorithm/slide_window.md)
39-
- [二叉搜索树](advanced_algorithm/binary_search_tree.md)
40-
- [回溯法](advanced_algorithm/backtrack.md)
39+
- [递归思维](./advanced_algorithm/recursion.md)
40+
- [滑动窗口思想](./advanced_algorithm/slide_window.md)
41+
- [二叉搜索树](./advanced_algorithm/binary_search_tree.md)
42+
- [回溯法](./advanced_algorithm/backtrack.md)
4143

4244
## 心得体会
4345

@@ -53,6 +55,8 @@
5355

5456
开始刷题时,确实是无从下手,因为从序号开始刷,刷到几道题就遇到 hard 的题型,会卡住很久,后面去评论区看别人怎么刷题,也去 Google 搜索最好的刷题方式,发现按题型刷题会舒服很多,基本一个类型的题目,一天能做很多,慢慢刷题也不再枯燥,做起来也很有意思,最后也收到不错的 offer(最后去了宇宙系)。
5557

58+
回到最开始的问题,面试到底要刷多少题,其实这个取决于你想进什么样公司,你定的目标如果是国内一线大厂,个人感觉大概 200 至 300 题基本就满足大部分面试需要了。第二个问题是按什么顺序刷及如何提高效率,这个也是本 repo 的目的,给你指定了一个刷题的顺序,以及刷题的模板,有了方向和技巧后,就去动手吧~ 希望刷完之后,你也能自己总结一套属于自己的刷题模板,有所收获,有所成长~
59+
5660
## 推荐的刷题路径
5761

5862
按此 repo 目录刷一遍,如果中间有题目卡住了先跳过,然后刷题一遍 LeetCode 探索基础卡片,最后快要面试时刷题一遍剑指 offer。
@@ -71,7 +75,7 @@
7175

7276
![剑指offer](https://img.fuiboom.com/img/leetcode_jzoffer.png)
7377

74-
刷题时间可以合理分配,如果打算准备面试了,建议前面两部分 一个半月 (6 周)时间刷完,最后剑指 offer 半个月刷完,边刷可以边投简历进行面试,遇到不会的不用着急,往模板上套就对了~
78+
刷题时间可以合理分配,如果打算准备面试了,建议前面两部分 一个半月 (6 周)时间刷完,最后剑指 offer 半个月刷完,边刷可以边投简历进行面试,遇到不会的不用着急,往模板上套就对了,如果面试管给你提示,那就好好做,不要错过这大好机会~
7579

7680
> 注意点:如果为了找工作刷题,遇到 hard 的题如果有思路就做,没思路先跳过,先把基础打好,再来刷 hard 可能效果会更好~
7781
@@ -81,8 +85,18 @@
8185

8286
[我看过的 100 本书](https://github.com/greyireland/awesome-programming-books-1)
8387

84-
## 后续
88+
## 更新计划
8589

8690
持续更新中,觉得还可以的话点个 **star** 收藏呀 ⭐️~
8791

8892
【 Github 】[https://github.com/greyireland/algorithm-pattern](https://github.com/greyireland/algorithm-pattern) ⭐️
93+
94+
## 完成打卡
95+
96+
完成计划之后,可以提交 Pull requests,在下面添加自己的项目仓库,完成自己的算法模板打卡呀~
97+
98+
| 完成 | 用户 | 项目地址 |
99+
| ---- | ------------------------------------------------- | ------------------------------------------------------------------- |
100+
|| [wardseptember](https://github.com/wardseptember) | [notes(Java 实现)](https://github.com/wardseptember/notes) |
101+
|| [dashidhy](https://github.com/dashidhy) | [algorithm-pattern-python(Python 实现)](https://github.com/dashidhy/algorithm-pattern-python) |
102+
|| [binzi56](https://github.com/binzi56) | [algorithm-pattern-c(c++ 实现)](https://github.com/binzi56/algorithm-pattern-c) |

‎TODO.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# 计划
2+
3+
## v1
4+
5+
- [ ] 完善文档细节
6+
- [ ] 工程实现用到的算法解析
7+
- [ ] 周赛计划
8+
- [ ] 面试体系计划

‎basic_algorithm/dp.md

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ func canJump(nums []int) bool {
356356
> 你的目标是使用最少的跳跃次数到达数组的最后一个位置。
357357
358358
```go
359+
// v1动态规划(其他语言超时参考v2)
359360
func jump(nums []int) int {
360361
// 状态:f[i] 表示从起点到当前位置最小次数
361362
// 推导:f[i] = f[j],a[j]+j >=i,min(f[j]+1)
@@ -383,6 +384,26 @@ func min(a, b int) int {
383384
}
384385
```
385386

387+
```go
388+
// v2 动态规划+贪心优化
389+
func jump(nums []int) int {
390+
n:=len(nums)
391+
f := make([]int, n)
392+
f[0] = 0
393+
for i := 1; i < n; i++ {
394+
// 取第一个能跳到当前位置的点即可
395+
// 因为跳跃次数的结果集是单调递增的,所以贪心思路是正确的
396+
idx:=0
397+
for idx<n&&idx+nums[idx]<i{
398+
idx++
399+
}
400+
f[i]=f[idx]+1
401+
}
402+
return f[n-1]
403+
}
404+
405+
```
406+
386407
### [palindrome-partitioning-ii](https://leetcode-cn.com/problems/palindrome-partitioning-ii/)
387408

388409
> 给定一个字符串 _s_,将 _s_ 分割成一些子串,使每个子串都是回文串。
@@ -486,32 +507,37 @@ func wordBreak(s string, wordDict []string) bool {
486507
}
487508
f := make([]bool, len(s)+1)
488509
f[0] = true
489-
max := maxLen(wordDict)
510+
max,dict := maxLen(wordDict)
490511
for i := 1; i <= len(s); i++ {
491-
for j := i - max; j < i && j >= 0; j++ {
492-
if f[j] && inDict(s[j:i]) {
512+
l := 0
513+
if i - max > 0 {
514+
l = i - max
515+
}
516+
for j := l; j < i; j++ {
517+
if f[j] && inDict(s[j:i],dict) {
493518
f[i] = true
494-
break
519+
break
495520
}
496521
}
497522
}
498523
return f[len(s)]
499524
}
500525

501-
var dict = make(map[string]bool)
502526

503-
func maxLen(wordDict []string) int {
527+
528+
func maxLen(wordDict []string) (int,map[string]bool) {
529+
dict := make(map[string]bool)
504530
max := 0
505531
for _, v := range wordDict {
506532
dict[v] = true
507533
if len(v) > max {
508534
max = len(v)
509535
}
510536
}
511-
return max
537+
return max,dict
512538
}
513539

514-
func inDict(s string) bool {
540+
func inDict(s string,dictmap[string]bool) bool {
515541
_, ok := dict[s]
516542
return ok
517543
}

‎data_structure/linked_list.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,8 @@ func hasCycle(head *ListNode) bool {
379379
fast := head.Next
380380
slow := head
381381
for fast != nil && fast.Next != nil {
382-
if fast.Val == slow.Val {
382+
// 比较指针是否相等(不要使用val比较!)
383+
if fast == slow {
383384
return true
384385
}
385386
fast = fast.Next.Next
@@ -389,7 +390,7 @@ func hasCycle(head *ListNode) bool {
389390
}
390391
```
391392

392-
### [linked-list-cycle-ii](https://leetcode-cn.com/problems/https://leetcode-cn.com/problems/linked-list-cycle-ii/)
393+
### [linked-list-cycle-ii](https://leetcode-cn.com/problems/linked-list-cycle-ii/)
393394

394395
> 给定一个链表,返回链表开始入环的第一个节点。 如果链表无环,则返回 `null`
395396
@@ -581,6 +582,6 @@ func copyRandomList(head *Node) *Node {
581582
- [ ] [sort-list](https://leetcode-cn.com/problems/sort-list/)
582583
- [ ] [reorder-list](https://leetcode-cn.com/problems/reorder-list/)
583584
- [ ] [linked-list-cycle](https://leetcode-cn.com/problems/linked-list-cycle/)
584-
- [ ] [linked-list-cycle-ii](https://leetcode-cn.com/problems/https://leetcode-cn.com/problems/linked-list-cycle-ii/)
585+
- [ ] [linked-list-cycle-ii](https://leetcode-cn.com/problems/linked-list-cycle-ii/)
585586
- [ ] [palindrome-linked-list](https://leetcode-cn.com/problems/palindrome-linked-list/)
586587
- [ ] [copy-list-with-random-pointer](https://leetcode-cn.com/problems/copy-list-with-random-pointer/)

‎data_structure/stack_queue.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ func updateMatrix(matrix [][]int) [][]int {
513513
## 总结
514514

515515
- 熟悉栈的使用场景
516-
- 后出先出,保存临时值
516+
- 后入先出,保存临时值
517517
- 利用栈 DFS 深度搜索
518518
- 熟悉队列的使用场景
519519
- 利用队列 BFS 广度搜索

‎introduction/golang.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ math.MinInt64
9494
copy
9595

9696
```go
97-
// 删除a[i],可以用 copy 将i+1到末尾的值覆盖到i到末尾-1
98-
copy(a[i:],b[i+1:])
97+
// 删除a[i],可以用 copy 将i+1到末尾的值覆盖到i,然后末尾-1
98+
copy(a[i:],a[i+1:])
9999
a=a[:len(a)-1]
100100

101101
// make创建长度,则通过索引赋值
@@ -112,7 +112,7 @@ a=append(a,x)
112112

113113
```go
114114
// byte转数字
115-
s="12345"
115+
s="12345"// s[0] 类型是byte
116116
num:=int(s[0]-'0') // 1
117117
str:=string(s[0]) // "1"
118118
b:=byte(num+'0') // '1'

‎practice_algorithm/bplus.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# b+ tree (MySQL 索引实现)

‎practice_algorithm/data_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# 数据索引(kafka 稀疏索引)

‎practice_algorithm/skiplist.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# skiplist(Redis Zset 实现)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /