參加了 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