最近我们协助一位学员完成了 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、又不想赌运气,可以来私信我。