刚刚完成 Citadel Summer 2026 SWE Internship 的 Online Assessment,两道编程题都顺利 AC 了!整体难度中等偏上,时间控制在 70 分钟左右完成,题目很考验对基础数据结构的灵活运用、边界处理以及时间复杂度优化。平台是 HackerRank,经典的两道题形式。下面分享一下遇到的两道题,以及个人思路和经验总结。希望对后续刷 Citadel OA 2026 的同学有帮助!

Problem 1: Count Stable Subsegments
In an organization, there are n servers with capacities given in an array capacity. A contiguous subsegment [l, r] (with r – l + 1 >= 3) is considered stable if capacity[l] == capacity[r] and this value equals the sum of capacities from l+1 to r-1.
Return the total number of such stable subsegments.
思路分享: 这题本质是考察子数组(subarray)的条件判断。直接暴力枚举所有可能的 l 和 r(确保长度 >=3)是可行的,但需要优化区间和计算。
- 先计算前缀和 prefix[],这样 sum(l+1 to r-1) = prefix[r] – prefix[l+1]。
- 双重循环遍历所有 l 和 r(r >= l+2),检查 capacity[l] == capacity[r] 且等于中间 sum。
- 注意边界:当长度正好为 3 时,中间 sum 就是一个元素;长度更长时正常计算。 时间复杂度 O(n²),n 一般在 10^5 以内,足够通过。重点是处理好前缀和的索引和空中间的情况(虽然长度>=3 不存在空)。
这题边界较多,容易在 sum 计算或索引上栽跟头,建议多测几个例子如 [3,3,3] 和 [9,3,3,3,9]。
Problem 2: Collect Goodness of Strictly Increasing Subsequences
Given an array of integers, consider all possible strictly increasing subsequences (including single elements)。For each such subsequence, compute its “goodness” value through cumulative bitwise OR operations along the subsequence.
Collect all unique goodness values from all strictly increasing subsequences, and return them in sorted order.
思路分享: 这题考察子序列(subsequence)和位运算的结合,需要动态维护可能的 goodness 值。
- 用一个 set 来维护当前所有可能的 goodness 值(初始可加入 0,如果空子序列算)。
- 为了处理严格递增,需要跟踪每个 goodness 对应的最后一个元素(可以用 map 或 pair 的 set)。
- 遍历数组时,对于当前 nums[i],遍历当前 set 中的所有状态,如果 nums[i] > 上一个元素的 last_val,则计算 new_goodness = old_goodness | nums[i],加入临时 set。
- 遍历完当前元素后,合并临时 set 到主 set,并更新 last_val 为 nums[i]。
- 最后将 set 转为 sorted list 返回。
关键优化:避免爆炸式增长,用 set 去重;如果不跟踪 last_val,会错过严格递增条件。时间复杂度取决于状态数,但实际案例中控制在合理范围。
整体来说,这轮 Citadel OA 2026 的题风很典型:一道 subarray + prefix sum 计数,一道 subsequence + DP-like 状态维护 + 位运算。难度接近 LeetCode Medium-Hard,建议重点刷数组/前缀和、DP、位运算、子序列相关题。
为什么 90% 的人会挂在 Hidden Cases 上?
Citadel 的 OA 系统非常狡猾。
- 超时陷阱: Q1 如果不用前缀和,或者 Python 写得太慢,在大数据量下必挂。
- 边界条件: Q2 中,如果数组为空?如果全是负数?如果全是重复数字?
- Code Style: 就算你能 Pass,如果代码写得像“实习生”而非“工程师”,在 Hiring Manager Review 阶段依然会被刷。
我们提供的不仅仅是答案,而是 Offer 的入场券。
- Real-time Assistance: 我们的 Senior Engineer 会通过屏幕共享,实时指导你 Coding。不是发给你代码复制粘贴,而是让你看着我们写,或者我们通过语音教你如何 “Think Aloud”,让面试过程滴水不漏。
- Original Code: 每一行代码都由真人现场编写,绝对通过 CodeSignal 的 Plagiarism Check(查重)。
- Safety First: 我们不仅保结果,更保安全。全流程模拟真实做题节奏,拒绝秒写,拒绝机械化操作。
Citadel 2026 的招聘窗口期极短。 你还在对着 LeetCode 刷题焦虑吗? 现在的就业环境,机会 > 实力,速度 > 完美。
立即联系 ProgramHelp 发送暗号 【Citadel OA 2026】 。