算法面试通关-课程综述
算法的道
- Chunk it up
- Deliberate practicing
- Feedback(leetcode)
庖丁解牛(Chunk it up):


刻意练习(Deliberate practicing)
练习缺陷,弱点
获得反馈
即时反馈
主动型反馈
-⾼⼿代码 (GitHub, LeetCode, etc.)
被动式反馈(⾼⼿给你指点)
- code review
切题四件套:
- Clarification
- Possible solutions:CodingCoding
- compare(time/space)
- optimal
- Coding
- Test cases
算法复杂度
时间复杂度
def fib(n):
if n == 0 or n == 1:
return n
return fib(n - 1) + fib(n - 2)

Master Theorem

class program
{
static void Main(string[] args)
{
int i;
i = x(x(8));
}
static int x(int n)
{
if (n <= 3)
return 1;
else
return x(n - 2) + x(n - 4) + 1;
}
}
递归算法x(x(8))需要调用几次函数x(int n)? 18

https://leetcode-cn.com/problems/two-sum/
1 public int[] twoSum(int[] nums, int target) {
2
3 int [] result = new int[2];
4 HashMap<Integer,Integer> map = new HashMap<>();
5 map.put(nums[0], 0);
6 for(int i = 1; i <= nums.length - 1;i++){
7 if(map.containsKey(target - nums[i])) {
8 result[0] = map.get(target - nums[i]);
9 result[1] = i;
10 }
11 else {
12 map.put(nums[i], i);
13 }
14 }
15 return result;
16 }

浙公网安备 33010602011771号