为什么要学习 LeetCode? Why practice Leetcode?
- Enhance personal competitiveness; currently, development positions at companies in the internet, banking, and quantitative hedging sectors require coding tests.
- Improve coding speed, reduce development time at work, and increase personal free time.
- Exercise personal thinking, improve problem-solving abilities, and enrich perspectives on modeling problems.
灵茶山艾府 的练习思路
上手路线
- 偶尔三题
- 属于基础的算法类型没完全掌握的
- 按分数段来做负重训练,100分为一段
- 假如自己的分数是2000,找到自己的弱项,做难度为自己当前 rating+200 的相关题目。
- 多做构造题能有效提高自己的思维水平(开脑洞的能力),从而更快地找到切题入口。(构造题即 constructive algorithms,可以通过 problemset 页面右侧的 Filter Problems 来搜索)
- 大多数时候,思考 10 分钟没有思路可以直接看题解。这是因为如果思考 10 分钟没有思路,可能是有一个概念不知道,或者有一个观察错过了。在你训练的过程中,最好是解决更多的问题,积累更多的解题技巧。
- 题量很重要
- 1000题、2000题、3000题是一个门槛
按分类刷题
双指针
- 相向双指针
- 同向双指针
二分查找
- Red-Blue Painting Approach
链表
- Reverse
- Fast Slow Pointer。链表中点,环形链表入口
- 删除
二叉树
- DFS, Depth First Search
- BFS, Breadth First Search
- Pre-order, In-order, Post-order Traversal
- Level-order Traversal
回溯
- 子集型,选或不选
- 组合型,选哪个
- 排列型,排除已选
动态规划
- Dp principle
- Backup DP
- Linear DP
- State Machine DP
- Interval DP
- Tree DP
- etc
数据结构
- 线段树
- 树状数组
- 堆、大小顶堆
- 栈、单调栈
- 队列、优先队列
- etc
Details
做题的时候不要显示tag
构造题