最近刚帮一位同学拿下 Meta 26 SWE Intern OA ,四道 Codesignal 题全部 AC。说真的,这次的题风挺 Meta 的:不会给你特别 Hard 的算法,但非常强调实现细节、模拟能力、边界判断。如果你还抱着“刷完 LeetCode 经典 100 题就能过”的想法,那么你已经输在了起跑线。

Q1 — Minimum Sum After One Operation
题目概述
Given an array of positive integers nums, you may perform the following operation at most once:
Choose an index i and replace nums[i] with the sum of digits of nums[i].
Return the minimum possible total sum after performing zero or one operation.
示例
nums = [14, 7, 20]
替换 20 → 2 → 总和最小 → 29.
思路
这道题就是帮你热下手:
- 原始总和先算出来
- 对每个数字算 digit sum
- “替换前后”做个差
- 贪心取最小即可
难度不大,就是典型 Codesignal Q1 的味道。
Q2 — Delivery System Using Drones
这题很有“Meta 产品模拟”的感觉,不是算法难,而是步骤细。
题目概述
Given a target distance and a list of station positions, you must deliver a package to the target using drones.
A drone can fly at most 10 units including the final hop.
You must always:
- 从当前点带着货物走到最近的 station
- 用 station 的无人机把货物送出去(最多 10 units)
- 如果无人机没飞到 target → 你要空手走过去拿货物
- 重复直到送达 target
Return total distance with cargo.
关键点
Meta 非常喜欢这种“按题目给的步骤照写就好”的题。
真正要注意的是:
- stations 要先 sort,否则会翻车
- 走路时,只有“带着货物”的距离才要累计
- 模拟步骤不要脑补,按题目顺序来就万无一失
总体是实现题,但细节一堆。
Q3 — Battery Usage Simulation
这题是典型 Codesignal 中等难度的“动态资源管理”。
题目概述
You want to run your phone for total time t.
You have several batteries, each with capacity[i] (usable duration) and recharge[i] (time required to fully recharge).
You must follow the rules:
- 只能使用 fully-charged 电池
- 用完电池后立刻把它放回充电
- 如果需要用电池但是没有任何 fully-charged → return -1
Return 你用了几块电池才够时间 t;如果最后一块没用进去也必须所有电池都在充电状态,否则 return -1。
核心逻辑
cur维护当前时间k[i]是电池下一次充满的时间点- 能用的电池要满足
k[i] <= cur - 用完后更新
k[i] = cur + recharge[i] - 不断迭代直到
cur >= t
这题看似贪心,实际上就是模拟。难点是“最后一块没用进去”的判断,很多人被这里卡住。
Q4 — Primary + Secondary Arrays with Operations
这题在四道里最难,绝大多数人卡在这里。
题目概述
You’re given two arrays:primary and secondary, and a list of operations.
There are two types:
[0, index, val]→ update secondary[index] = val[1, targetSum]→ return count of pairs(i, j)such that
primary[i] + secondary[j] == targetSum
primary 不变,secondary 会频繁 update。
为什么遍历会超时?
- 如果你每次遍历 primary × secondary,就是 O(N*M) 完全爆炸
- 即使把 primary 做成 hashmap,然后遍历 secondary 也是 O(N+M),每次 query 都太大
实际解法 Meta 给的 hint 很明显:
“一种 array fixed / 一种 array dynamic”
→ 这是典型 two-sum with update 结构。
最佳解法:频率表 + 动态维护
- 对 primary 建 freq(固定不变)
- 对 secondary 建 freq(可动态修改)
- type=0 时更新:从 freqSec 中删旧值、加新值
- type=1 时查询:
枚举 primary 的 distinct key,查targetSum - key在 secondary 中的频率
→ O(P) 其中 P 是 primary 的 distinct 数量(通常远小于 n)
这题跟 LeetCode 1 / 560 的那些 Two-Sum frequency 思路一致,但多了 dynamic update。
ProgramHelp:北美 CS 求职终极解决方案与高阶服务矩阵
我们的团队由来自 FAANG (Google, Meta, Amazon 等) 的前资深工程师以及 CMU、Stanford 等名校校友组成,我们提供的不是低端中介服务,而是行业顶级的、专家级的求职保障。
| 服务名称 | 核心目标 | 适用平台 |
| OA 辅助/代写 | 确保所有测试用例 100% 通过 (All Cases Passed) | Codesignal, HackerRank, 牛客网, AMCAT 等 |
| 付款机制 | 不通过所有测试用例 不收费 | – |
| 操作安全 | 远程控制实现无痕操作 | – |