最近刚结束 ZipRecruiter 的 2026 NG OA,是那种“分级解锁”题型——做完第 1 题才能看到第 2 题。我这次四题全 AC,整体难度中等偏易,但逻辑抽象、实现要严谨。下面是详细复盘 + 改过的新题数据版本,想准备 OA 的同学可以直接参考。
ZipRecruiter OA 概览
| 内容 | 说明 |
|---|---|
| 题目总数 | 4 题(分级解锁) |
| 题型方向 | 模拟内存数据库,逐步增加功能 |
| 难度层级 | Level 1 简单 → Level 4 稍复杂 |
| 核心考点 | 数据结构设计、TTL 时间管理、备份恢复逻辑 |
| 使用语言 | Python(dict 实现即可) |
Level 1 – Basic CRUD Operations
Problem Description
Implement a basic in-memory database that supports the following operations:
set(key: str, field: str, value: str) -> None
get(key: str, field: str) -> str | None
delete(key: str, field: str) -> bool
Requirements:
- Each record is identified by a unique
key. - Each record contains multiple
field-valuepairs. set()inserts or updates the field.get()retrieves the value if it exists.delete()removes the field if it exists and returns a boolean.
Example (with updated data)
| Operation | Return | Database State |
|---|---|---|
set("user_77", "name", "Alice") |
— | {"user_77": {"name": "Alice"}} |
set("user_77", "email", "a@x.com") |
— | {"user_77": {"name": "Alice", "email": "a@x.com"}} |
get("user_77", "name") |
"Alice" |
— |
delete("user_77", "name") |
True |
{"user_77": {"email": "a@x.com"}} |
get("user_77", "name") |
None |
— |
Level 2 – Scanning and Prefix Filtering
Problem Description
Extend your in-memory database to support listing fields and filtering by prefix.
scan(key: str) -> list[str]
scan_by_prefix(key: str, prefix: str) -> list[str]
Requirements:
scan()returns all fields for a given key in lexicographic order.scan_by_prefix()returns only fields starting with the given prefix.- The output format should be:
["<field>(<value>)", ...]
Example (with updated data)
| Operation | Return |
|---|---|
set("session99", "a_token", "xxx") |
— |
set("session99", "b_count", "5") |
— |
set("session99", "cfg", "on") |
— |
scan("session99") |
["a_token(xxx)", "b_count(5)", "cfg(on)"] |
scan_by_prefix("session99", "b") |
["b_count(5)"] |
scan("unknown") |
[] |
Level 3 – Timestamps and TTL Management
Problem Description
Introduce timestamps and Time-To-Live (TTL) logic for all data operations.
Each operation now includes a timestamp parameter, and records with TTLs should expire after their valid period.
New Methods:
set_at(key: str, field: str, value: str, timestamp: int) -> None
set_at_with_ttl(key: str, field: str, value: str, timestamp: int, ttl: int) -> None
get_at(key: str, field: str, timestamp: int) -> str | None
delete_at(key: str, field: str, timestamp: int) -> bool
Example (updated dataset)
| Timestamp | Operation | Output | Explanation |
|---|---|---|---|
| 10 | set_at_with_ttl("cache1", "val", "X", 10, 7) |
— | Valid within [10, 17) |
| 12 | get_at("cache1", "val", 12) |
"X" |
Still valid |
| 18 | get_at("cache1", "val", 18) |
None |
Expired |
| 20 | set_at("cache1", "tag", "v2", 20) |
— | Permanent field |
Implementation Notes:
- Each field can be represented as:
db[key][field] = {"val": value, "start": timestamp, "ttl": ttl or None}
Expired when: current_timestamp >= start + ttl
Always clean up expired entries before every operation.
Level 4 – Backup and Restore Functionality
Problem Description
Add backup and restore features to maintain database snapshots over time.
New Methods:
backup(timestamp: int) -> int
restore(timestamp: int, timestamp_to_restore: int) -> None
Example (updated data)
| Timestamp | Operation | Output | Explanation |
|---|---|---|---|
| 5 | set_at_with_ttl("s", "k1", "v1", 5, 10) |
— | Active in [5, 15) |
| 9 | backup(9) |
1 |
Saves snapshot with 6 seconds remaining TTL |
| 20 | restore(20, 9) |
— | TTL recalculated: [20, 26) |
| 25 | get_at("s", "k1", 25) |
"v1" |
Still valid |
| 27 | get_at("s", "k1", 27) |
None |
Expired |
Programhelp 助攻,让你的大厂之路更稳更快!
无论是 Amazon、Google 还是 OpenAI 的 OA、VO,我们都已经帮过上千名学员顺利拿下 offer!Programhelp 专注 大厂笔试 & 面试全流程助攻:
OA无痕联机助攻:HackerRank、CodeSignal、Codility 全覆盖,100% 过测不过包退;
语音实时提醒助攻:在 VO 面试中即时提示思路,帮你稳答高频题;
Mock 模拟 & 框架梳理:提前演练真实场景,训练出大厂标准答题逻辑;
我们见证了无数普通背景的同学,从卡在 OA 到轻松斩获大厂 offer。
如果你也想在下一场笔试或面试中无压力拿下,通过 Programhelp,让准备更高效、表现更完美!