一些题目
Part1
https://zhuanlan.zhihu.com/p/32626732052
实现 NMS,七八次,很高频;
实现 MultiHeadSelfAttention,大概 三四次;
用 Numpy 或者 List 实现MLP 的前向和反向,4次;
Leetcode 岛屿数量,大概得五六次;
Leetcode 反转链表以及衍生的,3次;
Leetcode 数组中第K大的数,2次;
Leetcode 编辑距离,最长递增子序列、买卖股票等等,其他的记不清了;
Part2
1.环形数组的滑动窗口问题
数组由不同颜色的球组成,求包含全部颜色的数组最短长度
2.m个完全相同的球放到n个完全相同的盘子中,问有几种不同的方法(区分盘子可为空or不可为空)
Part3
Part4
面试笔记:https://zhuanlan.zhihu.com/p/1902504372501480468
Part5
二维矩阵中最长递增路径,可以上下左右4个方向移动
class solution:
def longestIncreasingPath(self, matrix):
if not matrix or not matrix[0]:
return 0
m, n = len(matrix), len(matrix[0])
dp = [[0] * n for _ in range(m)]
max_len = 0
for i in range(m):
for j in range(n):
current_len = self.dfs(dp, i, j, m, n)
if current_len > max_len:
max_len = current_len
return max_len
def dfs(self, dp, i, j, m, n):
if dp[i][j] != 0:
return dp[i][j]
max_path = 1
directions = [(-1, 0), (1, 0), (0, -1), (0, 1)]
for dx, dy in directions:
x, y = i + dx, j + dy
if 0 <= x < m and 0 <= y < n and matrix[x][y] > matrix[i][j]:
max_path = max(max_path, 1 + self.dfs(dp, x, y, m, n))
dp[i][j] = max_path
return max_path
测试code
# 示例测试
matrix = [
[9, 9, 4, 1],
[11, 9, 8, 1],
[12, 1, 1, 1]
]
solu = solution()
print(solu.longestIncreasingPath(matrix)) # 输出:6
4070

被折叠的 条评论
为什么被折叠?



