这3场面试节奏很快,题目本身不复杂,核心在于定义是否清楚、抽象是否到位,以及被打断时还能继续推进。
Problem 1 — Repeat Customers
Original Problem
Given an access log for a feature, count the number of repeat customers.
A repeat customer is defined as a customer who has used the feature on more than one day.
Each line contains:<timestamp>\t<customer_id>
面试一开始会确认定义:
“more than one day”指的是不同日期。
实现方式直接落在数据结构上:
customer_id -> set(date)- 逐行解析log,提取日期
- 放入set去重
- 统计set大小大于1的用户数量
关键细节在时间处理:
timestamp需要转成date再存
同一天不同时间需要被视为同一次访问
时间复杂度 O(n),空间 O(n)
Problem 2 — Rubber Bands Grouping
Original Problem
Given a collection of interconnected rubber bands, separate them into as many distinct groups as possible such that no single color appears in more than one group.
Return an array representing the size of each group.
Example:
s = "abc" → [1,1,1]
s = "abcabc" → [4,1,1]
输入是字符串,抽象之后是图结构:
- 字符表示节点
- 相邻位置形成连接关系
- 相同字符在不同位置之间形成约束
处理方式可以直接用并查集:
- 初始化每种颜色为一个集合
- 根据相邻关系做 union
- 最终按 root 聚合统计每组大小
返回每个连通块的总数量
时间复杂度接近 O(n)
Problem 3 — Minimum Path Sum
Original Problem
给定一个 grid:
[
[1,3,1],
[1,5,1],
[4,2,1]
]
从左上到右下,只能向右或向下,求路径最小和。
状态定义很直接:
dp[i][j] 表示走到当前位置的最小路径和
转移关系:
dp[i][j] = grid[i][j] + min(dp[i-1][j], dp[i][j-1])
第一行和第一列是前缀累加。
时间复杂度 O(m * n),空间 O(m * n),可以压缩到一维。
面试里的真实感受
第一题在确认定义
第二题在做抽象
第三题在看熟练度
中间会不断被打断,比如让你解释数据结构选择,或者直接让你换一种实现方式。
关于面试辅助
这种场景里,差距通常出现在两点:
- 思路表达是否清晰
- 细节是否在第一时间说出来
在面试过程中,如果有人能实时把关键点补齐,比如“date处理”、“并查集建模”、“dp状态定义”,节奏会明显顺很多。
这也是为什么越来越多人开始用 面试辅助。
我们也有代面试,面试辅助,OA代写等服务助您早日上岸~

