最近我們協助一位學員完成了 Intuit 的 Online Assessment。這一輪 OA 的考察維度非常“刁鑽”:它不像 Google 或 Meta 那樣只考純演算法,而是混合了 系統指令碼 (Bash)、資料庫 (SQL) 和 高難度數學思維 (Math/DP)。
很多刷了 500+ LeetCode 的同學,遇到 Bash 文字處理 直接懵圈,或者在 Grid Coloring 的數學推導上浪費了 40 分鐘,最後慘遭 Reject。
記住:OA 是機器判卷,All Test Cases Passed 才是硬道理。 哪怕一個 Edge Case 沒過,你的簡歷可能就永遠躺在系統裡了。

T1 — SQL Duplicate Records
Clumsy Administrator
Your company maintains employee records in a database.
Due to some administrative issues, employee records have been inserted multiple times into the employee table.
A record is considered a duplicate only when all columns (fields) of that record are exactly the same.Write a query to find the names of employees whose complete records appear more than once in the table.
Each name should appear only once in your results.
Order does not matter.
我的解題思路
這題屬於見招拆招:“題目怎麼問,你就怎麼查”。
關鍵點:
- Duplicate = all columns identical
- 所以需要 group by 所有列
- having count(*) > 1
- 再選 distinct name,避免重複姓名出現在結果
屬於 SQL 最喜歡考的“明明很簡單,但有人會急著 overthink” 的型別。
T2 — Coloring a Grid(容斥原理本體)
You are given an n × 3 grid.
Determine the number of valid ways to color the grid using red, green, and blue, such that no row or column contains cells that are all the same color.
Since the result may be large, return the answer modulo 109+710^9 + 7109+7.
Example:
n = 4 → total patterns = 296490
完整數學推導(更細節版)
這題乍看很“動態規劃式”,但其實可以直接用容斥,推起來更快。
如果把每一行看成一個由 3 色構成的排列,由於:
- 3 列 × 3 顏色
- 每行不能全一樣 → 3 choices^3 − 3
但 Intuit 版本通常是標準容斥版本:
Total patterns if no restriction:
24n24^n24n
因為每一行有 24 種合法配色(不重複排列),然後獨立 n 行。
Now treat “a whole column has same color” as a bad event.
- 1 column same → subtract
- 2 columns same → add back
- 3 columns same → subtract
完全就是: Ans=24n−3⋅6n+3⋅3n−3n\text{Ans} = 24^n – 3 \cdot 6^n + 3 \cdot 3^n – 3^nAns=24n−3⋅6n+3⋅3n−3n
(不同版本常見,有時 base 是 12/18/24,看具體題面限制,但 Intuit 這題通常是 color-permutation model,所以 24^n 屬於最常見版本。)
T3 — Bash 3.2: Text Cleaner(最陰間的一題)
You will write a Bash 3.2 script that “cleans text”.
A token is obtained by treating certain characters as separators.
You must:
- Convert the entire input text to lowercase
- Remove any token that contains at least one non-alpha printable ASCII character
- Remove tokens that appear in a stop word list
- Print the cleaned tokens, space-separated
Token separators include:
double quote, single quote, comma, period, semicolon, space, hyphen, exclamation mark, question mark, etc.
Stop words include:
“of”, “the”, “a”, “by”, “is”, … (題中給整段)
我的詳細思路(擴充套件版+避雷重點)
這題真的坑巨多,如果你沒有寫過 Bash 3.2 的 regex,那就像是被迫使用石器時代工具造現代程式。
Step 1: 讀取並拼接全部文字
常見小坑:
- 輸入不是一行
- 不能逐行簡單 echo,需要 read + 拼接陣列
- newline 全被當作 separator
Step 2: 轉成 lower-case
必須先 lower-case,再去比較 stop words,否則大小寫不一致會導致 stop words 不被過濾。
這點超級多人翻車。
Step 3: 替換所有 token separators 為空格
手寫正則:
tr '",.;:?!- ' ' '
注意:
- 不能直接用
[[:punct:]],因為題目要求“只處理指定的符號” - 多個空格需要壓縮成一個空格
Step 4: Split tokens & filter invalid words
你需要手動:
- 用空格 split
- 對每個 token 做:
- 至少一個非字母字元 → 丟棄
- 是 stop word → 丟棄
Bash 3.2 裡,判斷必須用:
[[ $token =~ ^[a-z]+$ ]]
Step 5: 輸出 cleaned tokens(空格分隔)
不能換行,必須一個 line。
我的最終感受:T1 溫柔,T2 規整,T3 隱藏殺機
- T1 = 送分題,寫多少給多少
- T2 = 數學題,但能推則秒殺
- T3 = 真正壓時間的一題,尤其是 Bash 正則細節+ stop words 過濾順序。
我做 T3 時卡了快十分鐘,要不是經驗足,基本要寄。
如果你之後要打 Intuit、Google、Stripe、Meta、Amazon、TikTok 那類 HackerRank OA:
- 全程 90min
- 題型混合(SQL / Bash / Python / 數學推導都有可能)
- 最容易翻車的永遠是實現細節題
如果你想穩(尤其想 All Testcases Passed)
我這邊長期:
北美各大廠 OA 穩過輔導
聯機無痕助攻(ToDesk / 不被檢測)
卡點語音提醒
不過不收費
Google / Amazon / Meta / Stripe / TikTok / Tesla /…全覆蓋
秋招越到後期,時間越貴。
如果你有 upcoming OA、又不想賭運氣,可以來私信我。