参加了 Meta 的 SDE 面试流程,整体包括 三轮 Coding、一轮 Behavioral、一轮 System Design,总共分两天进行,都是线上。这篇主要记录每一轮的题目类型和解题思路,重点放在题本身,方便复盘刷题。
一、五轮概览
| 轮次 | 类型 | 题目 |
|---|---|---|
| 第一轮 | Coding | Word Search II(Trie)+ Search in Rotated Sorted Array |
| 第二轮 | Coding | 至多 K 个不同字符的最长子串 + Shortest Distance from All Buildings |
| 第三轮 | Behavioral | conflict / decision / leadership(TPM 主导) |
| 第四轮 | Coding | 最短状态转换 BFS + Product of Two RLE Arrays |
| 第五轮 | System Design | Real-time Notification System |
二、第一轮 Coding:Word Search II + Rotated Array
第一题:Word Search II(Trie 剪枝)
类似 LeetCode 212,但题面更开放:给一个字符矩阵和单词列表,返回所有能从矩阵中找到的单词,路径上下左右移动、不能重复使用同一位置。暴力 DFS 容易超时。面试官提示「can we avoid re-visiting certain paths」后,我立刻改成 Trie + DFS 剪枝。
def find_words(board, words):
trie = {}
for w in words: # 建前缀树,叶子存完整单词
node = trie
for c in w:
node = node.setdefault(c, {})
node['#'] = w
R, C, res = len(board), len(board[0]), set()
def dfs(r, c, node):
ch = board[r][c]
if ch not in node:
return
nxt = node[ch]
if '#' in nxt:
res.add(nxt['#'])
board[r][c] = '*' # 标记访问,避免重复使用
for dr, dc in ((1,0),(-1,0),(0,1),(0,-1)):
nr, nc = r+dr, c+dc
if 0 <= nr < R and 0 <= nc < C and board[nr][nc] != '*':
dfs(nr, nc, nxt)
board[r][c] = ch # 回溯
for i in range(R):
for j in range(C):
dfs(i, j, trie)
return list(res)
补充了 visited 标记、路径拼接和前缀 pruning,最后通过所有 test case。
第二题:Search in Rotated Sorted Array
老 tagged 题,二分变体,秒了。
三、第二轮 Coding:滑动窗口 + Shortest Distance from All Buildings
第一题:至多 K 个不同字符的最长子串(返回子串本身)
经典 sliding window,但有个 twist:返回子串实际内容,而不是长度。用 hash map 记录字符频次,双指针维护窗口,超过 K 就收缩。
def longest_k_distinct(s: str, k: int) -> str:
cnt = {}
left = best_l = best_len = 0
for right, ch in enumerate(s):
cnt[ch] = cnt.get(ch, 0) + 1
while len(cnt) > k: # 超过 K 个不同字符,收缩左边界
cnt[s[left]] -= 1
if cnt[s[left]] == 0:
del cnt[s[left]] # 频次为 0 必须移出,否则 len(cnt) 不准
left += 1
if right - left + 1 > best_len:
best_len, best_l = right - left + 1, left
return s[best_l:best_l + best_len]
面试官细节要求挺高:为什么频次为 0 的字符要移出 hash table(否则 len(cnt) 失真)、如何处理 Unicode 字符、能否用 Counter 替代 dict。
第二题:Shortest Distance from All Buildings
hard 题,多源 BFS,之前刷过,比较顺。
四、第三轮 Behavioral
面试官是 TPM,问题围绕 conflict resolution、decision making、leadership。
- 跨团队 collaboration 困难:我举了推动 schema 变更但后端资源迟迟不到位的例子。她追问「how did you communicate」「结果有没有影响 release」。
- Failure:对 traffic 高峰预估不足导致系统 overloading 的事件,她追问怎么总结的、有没有做 postmortem。
整体考察真实经验和复盘能力,氛围不错。
五、第四轮 Coding:最短状态转换 BFS + RLE
第一题:最短状态转换路径
给定初始状态、终止状态和一系列合法转换规则(+1、-1、×2、÷2 等),找最短转换路径。我先问能否重复访问状态,面试官说「yes but only if the state is meaningful again」——重复状态必须有新路径意义。
from collections import deque
def min_transforms(start, target, ops):
q = deque([(start, 0)])
visited = {start}
while q:
state, steps = q.popleft()
if state == target:
return steps
for nxt in ops(state): # ops 生成所有合法的下一状态
if nxt not in visited:
visited.add(nxt) # lazy visited marking 防死循环 / OOM
q.append((nxt, steps + 1))
return -1
面试官追问 状态空间特别大时怎么防 OOM,我答可以加边界条件和 lazy visited marking,并讲了 time/space 瓶颈。
第二题:Product of Two Run-Length Encoded Arrays
LC 原题,双指针对齐 run 长度,很顺。
六、第五轮 System Design:Real-time Notification System
设计一个 实时通知系统:支持海量用户 subscribe、低延迟推送、多端支持,保证 HA 和可扩展性。
我先拆模块:Producer、Message Queue、Dispatcher、Device Registry、Delivery Tracker。
| 模块 | 方案 | 理由 |
|---|---|---|
| Message Queue | Kafka | partition + 持久化 |
| Dispatcher | stateless 水平扩展 | consumer group 负载均衡 |
| Device Registry | Redis | 记录每用户活跃设备 |
| 可靠性 | retry queue + 指数退避 + DLQ | 消息不丢 |
| QoS | VIP 优先队列 | 重要消息优先 |
| 可观测性 | Prometheus(delivery latency / fail rate) | 上线后监控 |
面试官不断深入:「Dispatcher 宕机怎么办」「用户设备离线怎么处理」。我用 retry queue + exponential backoff + dead-letter queue 回应,并补了 QoS 控制和监控指标。明显感受到 system design 不是讲概念,而是要考虑实际运行中的 故障与延迟容忍度。
七、总结
Meta 的面试题并不偏难题型,但非常注重 细节和思路完整性:Coding 重 clean code 和边界处理(频次清零、visited marking、Unicode);Behavioral 问得深但可准备;System Design 要求结构清晰、合理拆分,并能深入每个模块的设计动因与扩展策略。
FAQ
Q1:Meta SDE 面试几轮、什么结构?
这个 case 是五轮:三轮 Coding、一轮 Behavioral、一轮 System Design,分两天线上完成。
Q2:Meta 的 Coding 偏什么题型?
高频题居多:Word Search II(Trie 剪枝)、滑动窗口(至多 K 个不同字符)、多源 BFS(Shortest Distance from All Buildings)、状态转换 BFS、RLE。难点不在题,而在 clean code 和边界细节(频次清零、visited marking、Unicode)。
Q3:Meta 的 System Design 怎么准备?
以 real-time notification 为例:先拆 Producer / Queue / Dispatcher / Registry / Tracker,选 Kafka + stateless Dispatcher + Redis,重点准备故障处理(Dispatcher 宕机、设备离线、retry + DLQ)和可观测性,而不是只背架构图。
Q4:怎么高效练 Meta 这五轮?
把高频 coding 练到能边写边讲边界,system design 按「拆模块 → 选型 → 故障 → 监控」四步推演。如果想要这几道真题的限时陪练、notification system 专项,或需要 VO辅助 / VO代面 的实时对接,可以发岗位 JD 先做题型预测再排练习计划。
正在准备 Meta 面试?
Meta 考的是 clean code + 边界细节 + system design 的拆解深度。oavoservice 提供 Meta 全流程陪练:Word Search II / 滑动窗口 / 状态转换 BFS 限时模拟、notification system 设计推演、TPM 风格 BQ 演练,也支持 VO辅助 / VO代面 的实时对接。教练含前 Meta 资深工程师,熟悉「coding 重细节、system design 挖故障」的评分风格。
立即添加微信 Coding0201,获取 Meta 真题与陪练。
联系方式
- 微信:Coding0201
- Email:[email protected]
- Telegram:@OAVOProxy