https://github.com/LongxingTan/Machine-learning-interview
- 算法工程师-机器学习-数据科学家面试准备1- 概述 外企和国外公司、春招、秋招
- 算法工程师-机器学习-数据科学家面试准备2- Leetcode 300
- 算法工程师-机器学习-数据科学家面试准备3-系统设计
- 算法工程师-机器学习-数据科学家面试准备4-ML系统设计
整体目标
- lc: 总量600~800,其中高频300熟悉,且能bug free的写出多种解法
- ml: 熟悉推荐系统与NLP,常见场景系统设计,模型发展的脉络,常用模型的理论与优化
2023-九月刷题
序号 | 日期 | 题目 | 评论 |
---|---|---|---|
1 | 0918 | 33. Search in Rotated Sorted Array | 1. 有一半必然存在单调,二分 2. 各种边界 |
2 | 0918 | 209. Minimum Size Subarray Sum | 滑动窗口,理论上一次循环,右边界在循环 |
3 | 0918 | 59. Spiral Matrix II | 左右都可以闭区间,否则开区间注意填充奇书中心值 |
4 | 0919 | 707. Design Linked List | 边界、循环等细节 |
5 | 0919 | 24. Swap Nodes in Pairs | 画图模拟,几个细节容易出错 |
6 | 0919 | 19. Remove Nth Node From End of List | 快慢指针 |
7 | 0920 | 142. Linked List Cycle II | 可以采用列表记录,或快慢指针,快指针回到起点 |
8 | 0920 | 454. 4Sum II | 记录前两个出现的和次数,再从后两个和中哈希查找 |
9 | 0920 | 15. 3Sum | 注意去重 |
10 | 0921 | 18. 4Sum | 和3sum基本一样,去重 |
11 | 0921 | 151. Reverse Words in a String | split 双指针 |
12 | 0921 | 150. Evaluate Reverse Polish Notation | 栈,字符串转实际运算符 |
13 | 0922 | 239. Sliding Window Maximum | 单调队列,和单调栈结合起来看 |
14 | 0922 | 347. Top K Frequent Elements | 字典或heap |
15 | 0922 | 102. Binary Tree Level Order Traversal | bfs |
16 | 0923 | 107. Binary Tree Level Order Traversal II | bfs |
17 | 0923 | 199. Binary Tree Right Side View | bfs |
18 | 0923 | 429. N-ary Tree Level Order Traversal | bfs |
19 | 0923 | 515. Find Largest Value in Each Tree Row | bfs |
20 | 0923 | 116. Populating Next Right Pointers in Each Node | bfs |
21 | 0923 | 117. Populating Next Right Pointers in Each Node II | bfs |
22 | 0924 | 513. Find Bottom Left Tree Value | bfs |
23 | 0924 | 106. Construct Binary Tree from Inorder and Postorder Traversal | 构造,从root开始,前序 |
24 | 0924 | 105. Construct Binary Tree from Preorder and Inorder Traversal | 构造,从root开始,前序 |
25 | 0925 | 654. Maximum Binary Treel | 构造 |
26 | 0925 | 98. Validate Binary Search Tree | 中序 |
27 | 0925 | 236. Lowest Common Ancestor of a Binary Tree | 祖先含义需要转化为理解 |
28 | 0925 | 235. Lowest Common Ancestor of a Binary Search Tree | |
29 | 0926 | 701. Insert into a Binary Search Tree | |
30 | 0926 | 450. Delete Node in a BST | |
31 | 0926 | 669. Trim a Binary Search Tree | |
32 | 0927 | 538. Convert BST to Greater Tree | 从右向左的中序遍历 |
33 | 0927 | 77. Combinations | 回溯:n叉树,树的宽度和深度;模版;增加path[:] copy |
34 | 0927 | 216. Combination Sum III | |
35 | 0928 | 17. Letter Combinations of a Phone Number | 理解这时树的宽度、深度分别对应什么 |
36 | 0928 | 39. Combination Sum | |
37 | 0928 | 40. Combination Sum II | 注意如何去重,排序,在单层逻辑前判断相等的话略过 |
38 | 0929 | 131. Palindrome Partitioning | |
39 | 0929 | 93. Restore IP Addresses | |
40 | 0929 | 78. Subsets | 回溯,前面的都是叶节点归入结果,子集是全部节点进入结果集 |
41 | 0929 | 90. Subsets II | 注意根据排序,和宽度时如何去重 |
42 | 0929 | 491. Non-decreasing Subsequences | 按树宽度去重,按set或hash去重,结果筛选 |
43 | 0929 | 46. Permutations | 树往下的时候,需要从剩余集合中选择,因此排列问题需要标记visited |
44 | 0929 | 47. Permutations II | 去重: 叶节点+visit判断 |
45 | 0930 | 332. Reconstruct Itinerary | |
46 | 0930 | 51. N-Queens | |
47 | 0930 | 37. Sudoku Solver | |
48 | 0930 | 376. Wiggle Subsequence | |
49 | 0930 | 53. Maximum Subarray | |
50 | 0930 | 122. Best Time to Buy and Sell Stock II | |
51 | 1008 | 55. Jump Game | 只记录覆盖范围并更新 |
52 | 1008 | 45. Jump Game II | 我会更习惯动态规划解法 |
53 | 1008 | 134. Gas Station | 贪心不好想,先掌握暴力模拟 |
54 | 1008 | 135. Candy | 两次模拟 |
55 | 1008 | 406. Queue Reconstruction by Height | 排序的key是关键 |
56 | 1008 | 452. Minimum Number of Arrows to Burst Balloons | |
57 | 1008 | 435. Non-overlapping Intervals | |
58 | 1008 | 763. Partition Labels | |
59 | 1009 | 56. Merge Intervals | |
60 | 1009 | 738. Monotone Increasing Digits | 字符串不能直接给一位赋值,list(str(n)) |
61 | 1009 | 968. Binary Tree Cameras | |
62 | 1010 | 62. Unique Paths | 2d 简单动态规划 |
63 | 1010 | 63. Unique Paths II | 障碍物初始化时,只有障碍物前的才会1 |
64 | 1010 | 343. Integer Break | 通过举例过程想到动态规划 |
65 | 1010 | 96. Unique Binary Search Trees | 通过举例过程想到动态规划,和上一题有点像 |
66 | 1011 | 416. Partition Equal Subset Sum | 要如何想到是背包? |
67 | 1011 | 1049. Last Stone Weight II | |
68 | 1011 | 494. Target Sum | |
69 | 1011 | 474. Ones and Zeroes | ?? |
70 | 1012 | 518. Coin Change II | |
71 | 1012 | 377. Combination Sum IV | |
72 | 1012 | 322. Coin Change | 经典题目 |
73 | 1013 | 279. Perfect Squares | |
74 | 1013 | 139. Word Break | 如何想到用背包? |
75 | 1013 | 198. House Robber | |
76 | 1014 | 213. House Robber II | |
77 | 1014 | 337. House Robber III | 树形DP |
78 | 1014 | 122. Best Time to Buy and Sell Stock II | 动归,第2维是状态,这里是持有或不持有 |
79 | 1014 | 123. Best Time to Buy and Sell Stock III | 完成2笔,就是0/1/2/3/4 |
80 | 1014 | 188. Best Time to Buy and Sell Stock IV | 123的2进一步参数化,for |
81 | 1014 | 309. Best Time to Buy and Sell Stock with Cooldown | 注意划分多个状态及状态见转移 |
82 | 1014 | 714. Best Time to Buy and Sell Stock with Transaction Fee | 和122类似,卖出时加上手续费 |
83 | 1015 | 300. Longest Increasing Subsequence | |
84 | 1015 | 718. Maximum Length of Repeated Subarray | |
85 | 1015 | 1143. Longest Common Subsequence | |
86 | 1015 | 1035. Uncrossed Lines | |
87 | 1015 | 53. Maximum Subarray | |
88 | 1015 | 115. Distinct Subsequences | |
89 | 1015 | 583. Delete Operation for Two Strings | |
90 | 1015 | 72. Edit Distance | |
91 | 1015 | 647. Palindromic Substrings | |
92 | 1015 | 516. Longest Palindromic Subsequence | |
93 | 1016 | 739. Daily Temperatures | 单调栈,没有很理解其初始化,自己独立写可能还是会出问题 |
94 | 1017 | 503. Next Greater Element II | |
95 | 1017 | 42. Trapping Rain Water | |
96 | 1017 | 84. Largest Rectangle in Histogram | |
97 | 1018 | 797. All Paths From Source to Target | |
98 | 1018 | 200. Number of Islands | |
99 | 1019 | 1020. Number of Enclaves | |
100 | 1019 | 417. Pacific Atlantic Water Flow | |
101 | 1020 | 130. Surrounded Regions |
2023十二月刷题
序号 | 日期 | 题目 | 评论 |
---|---|---|---|
1 | 1208 | 33. Search in Rotated Sorted Array | 1. 有一半必然存在单调,二分 2. 各种边界 |
二月计划
序号 | 日期 | 评论 |
---|---|---|
1 | 0213 | BFS+拓扑,阅读完FlagE结构 |
2 | 0214 | string + stack + queue |
2 | 0215 | dynamic programming |
2 | 0216 | greedy |
2 | 0217 | 小结, +推荐系统架构 |
2 | 0218 | LLM + retrievals架构 |
其他
- 代码随想录刷题总结
leetcode 有个 mock 的功能,每次全屏
查看discussion
Curated-List-of-Top-75-LeetCode-Questions-to-Save-Your-Time-OaM1orEU
列表
二叉树:
剑指offer
Remove Duplicates from Sorted Array
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.
Do not allocate extra space for another array, you must do this in place with constant memory.
For example, Given input array A = [1,1,2],
Your function should return length = 2, and A is now [1,2].
排序而且有重复,那么
- 记录下一个不重复的数值的位置,并自动向后移
- 找到其中新的不重复数值。或者单独一个值记录,或者根据前后是否发生变化
Remove Duplicates from Sorted Array II
Follow up for "Remove Duplicates": What if duplicates are allowed at most twice?
For example, given sorted array A = [1,1,1,2,2,3], your function should return length = 5, and A is now [1,1,2,2,3]