最近剛結束 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", "[email protected]") |
— | {"user_77": {"name": "Alice", "email": "[email protected]"}} |
get("user_77", "name") |
"Alice" |
— |
delete("user_77", "name") |
True |
{"user_77": {"email": "[email protected]"}} |
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:
["()", ...]
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,讓準備更高效、表現更完美!