Citadel SDE Intern OA 在量化金融公司里属于**"题面看着简单,但每题都隐含 1-2 个边界陷阱"的代表。HackerRank 上的 3 道题——Price Check 价格错误统计、Framing Text 矩形文字框、Recommendation System 共同好友推荐——每道题 LeetCode Easy~Medium,但 Citadel 评分系统对字符串格式精确度和边界完整性的要求是金融科技公司里最严苛的之一**。本文给出 2026 实习 OA 三道原题的完整 Python AC 解、复杂度分析与隐藏 case 防御。
Citadel SDE Intern OA 概览
| 维度 | 详情 |
|---|---|
| 平台 | HackerRank for Work |
| 时长 | 70 分钟 |
| 题量 | 3 道 |
| 难度 | LeetCode Easy ~ Medium |
| 通过率 | 约 25-30% |
| 投递岗位 | Citadel SDE Intern / Citadel Securities SDE Intern |
题目一:Price Check(价格错误统计)
题目描述
商店收银员手动输入商品价格,可能出错。给定:
products[n]:商品名列表productPrices[n]:商品的正确价格productSold[m]:实际售出的商品名列表soldPrice[m]:实际录入的售价列表
返回录入错误的次数。
示例:
products = ['eggs', 'milk', 'cheese']
productPrices = [2.89, 3.29, 5.79]
productSold = ['eggs', 'eggs', 'cheese', 'milk '] # 注意第 4 项尾随空格
soldPrice = [2.89, 2.99, 5.79, 3.29]
错误数 = 2 (eggs 第 2 次卖错,cheese 价格不对)
解题思路
构建 name → price 字典,逐项比对。Citadel 的隐藏 case 重点在:
- 商品名带前后空格(如
"milk ")需要.strip() - 浮点比较精度:用
abs(a - b) < 1e-2而非== - 未知商品(productSold 中出现 products 里没有的名字):题目期望"算作错误"
Python 完整解法
from typing import List
def price_check(
products: List[str],
product_prices: List[float],
products_sold: List[str],
sold_prices: List[float],
) -> int:
catalog = {p.strip(): pr for p, pr in zip(products, product_prices)}
errors = 0
for name, price in zip(products_sold, sold_prices):
key = name.strip()
if key not in catalog:
errors += 1
elif abs(catalog[key] - price) > 1e-2:
errors += 1
return errors
时间复杂度:O(n + m)
空间复杂度:O(n)
Citadel 隐藏 case
| 输入 | 期望 |
|---|---|
| productSold 含未知商品 | 算 1 个错误 |
| 商品名大小写不同 | 视为不同商品 |
| 浮点小误差(差 0.001) | 不算错误 |
题目二:Framing Text(矩形文字框)
题目描述
接收一行多个单词的字符串,输出按"一词一行"格式的矩形框,每个单词左右各留 1 空格。
示例输入:
"Hello World in a frame"
示例输出:
+-------+
| Hello |
| World |
| in |
| a |
| frame |
+-------+
解题思路
- 找到最长单词长度
L - 框宽度 =
L + 4(|+ 单词 + 右侧空格补齐 +|) - 每个单词左对齐 + 右侧空格补齐
Python 完整解法
def print_boxed_text(s: str) -> str:
words = s.split()
if not words:
return ""
max_len = max(len(w) for w in words)
border = "+" + "-" * (max_len + 2) + "+"
lines = [border]
for w in words:
padded = w.ljust(max_len)
lines.append(f"| {padded} |")
lines.append(border)
return "\n".join(lines)
时间复杂度:O(n × L)
空间复杂度:O(n × L)
Citadel 隐藏 case
| 输入 | 期望 |
|---|---|
"" 空字符串 |
返回空字符串(不要打印边框) |
| 多空格分隔 | split() 默认按任意空白分割 |
| 单个单词 | 正常输出单行 |
| 单词全是同一长度 | 边框宽度 = 单词长度 + 4 |
评分点:Citadel 对输出末尾换行敏感——返回字符串末尾不要多余 \n,否则 hidden test 失败。
题目三:Recommendation System(共同好友推荐)
题目描述
社交网络有 n 个用户(编号 0 到 n-1),m 对好友关系。为每个用户推荐共同好友最多的、当前不是好友的另一用户。如果有平局,选 index 最小的。如果没有候选,返回 -1。
示例:
n = 5
friendships = [[0,1], [0,2], [1,3], [2,3], [3,4]]
| 用户 | 已是好友 | 候选 | 共同好友 | 推荐 |
|---|---|---|---|---|
| 0 | {1, 2} | {3, 4} | 0&3 共同 {1,2}, 0&4 共同 {3} | 3 |
| 1 | {0, 3} | {2, 4} | 1&2 共同 {0,3}, 1&4 共同 {3} | 2 |
| 2 | {0, 3} | {1, 4} | 2&1 共同 {0,3}, 2&4 共同 {3} | 1 |
| 3 | {1, 2, 4} | {0} | 3&0 共同 {1,2} | 0 |
| 4 | {3} | {0,1,2} | 4&0 共同 {3}, 4&1 共同 {3}, 4&2 共同 {3} | 0 |
输出:[3, 2, 1, 0, 0]
解题思路
每个用户用 set 存好友。对每个用户 i:
- 遍历所有候选用户 j(不为 i,且不为 i 的好友)
- 计算
len(friends[i] & friends[j]) - 取最大且 j 最小
Python 完整解法
from typing import List
def recommend(n: int, friendships: List[List[int]]) -> List[int]:
friends = [set() for _ in range(n)]
for a, b in friendships:
friends[a].add(b)
friends[b].add(a)
result: List[int] = []
for i in range(n):
best_j = -1
best_count = -1
for j in range(n):
if j == i or j in friends[i]:
continue
count = len(friends[i] & friends[j])
if count > best_count or (count == best_count and j < best_j):
best_count = count
best_j = j
if best_count <= 0:
result.append(-1)
else:
result.append(best_j)
return result
时间复杂度:O(n² × avg_degree)
空间复杂度:O(n + m)
Citadel 隐藏 case
| 输入 | 期望 |
|---|---|
| 用户没有任何好友 | 返回 -1(无法计算共同好友) |
| 所有候选都 0 共同好友 | 返回 -1 |
自环 [i, i] |
题目通常不会给,但代码用 j == i 排除 |
| 重复好友对 | set 自动去重 |
Citadel 这道题的"狠"在于"0 共同好友 = -1"——不是返回 index 0 的候选用户。隐藏 case 至少有 1 个空图测试。
Citadel SDE Intern OA 通过策略
1)70 分钟分配
| 题目 | 建议时间 |
|---|---|
| Price Check | 10 分钟 |
| Framing Text | 15 分钟 |
| Recommendation System | 30 分钟 |
| 留 buffer 调试 | 15 分钟 |
2)字符串处理优先级
Citadel 评分对字符串格式严格匹配——前后空格、大小写、末尾换行都计较。提交前用 repr() 打印输出,目视检查。
3)Recommendation System 不必追求 O(n log n)
n 通常 ≤ 1000,O(n²) 即可 AC。不要为了优化引入新 bug。
FAQ
Citadel SDE Intern OA 通过率多少?
约 25-30%。Citadel 是量化金融岗位中OA 难度中等但通过率最低的公司之一——主要原因是简历筛选已经非常严,进入 OA 的候选人都是 top 院校 + 高 GPA。
这 3 道题在 2026 还会出吗?
会。Price Check 和 Framing Text 是 Citadel 题库长青题目,2024-2026 反复出现。Recommendation System 在 2026 实习季出现率约 40%,与 Process Allocation / Load Balancing 题型轮换。
Citadel HackerRank 允许跳题吗?
允许,但强烈建议按顺序做——Price Check 是 warm-up,做完心态稳。直接做 Recommendation System 容易超时。
OA 之后多久收到 onsite 邀请?
平均 3-5 个工作日。Citadel 速度比 JPMorgan / Goldman Sachs 快很多——快速决策是 Citadel 招聘文化的特点。
Citadel SDE Intern 和 Citadel Securities SDE Intern 的 OA 一样吗?
不一样。Citadel(hedge fund 主体)的 OA 偏算法 + 数据结构;Citadel Securities(market making)的 OA 多 1 道做市概率题或Pandas 数据处理题。
正在准备 Citadel SDE Intern OA?
oavoservice 提供 Citadel / Citadel Securities / Two Sigma / Jane Street / HRT 等量化金融公司 OA 全流程辅助:题型分类、隐藏 case 防御、Python 实战代码模板。我们的导师包括前 Citadel quant developer,对 Citadel 的"字符串严格匹配"评分风格有专门应对策略。
立即添加微信:Coding0201,获取 Citadel OA 一对一辅导。
#Citadel #CitadelOA #SDEIntern #HackerRank #量化金融 #OA真题
联系方式
Email: [email protected]
Telegram: @OAVOProxy