最近不少同学拿到了 Salient Technologies 的 OA(Online Assessment),题目风格堪称系统设计版的“地狱模式”——比普通算法题更偏向真实工程实现,包含多个功能阶段、异常处理、TTL(Time to Live)逻辑、版本回滚机制。
今天我们就带大家完整复盘这道题 —— 并告诉你,我们是如何在 CSOAHelp 实时指导下,一次性全过所有测试用例的。
📘 OA 原题(完整题面)
Title: Recording Storage System
Language: Python 3
🧩 Design Directive
Your task is to implement a simplified version of a recording storage service that manages audio/video recordings with time-to-live (TTL) functionality. All operations that should be supported are listed below. Partial credit will be granted for each test passed, so press "Submit" often to run tests and receive partial credits for passed tests.
Implementation Tips:
Read the question all the way through before you start coding, but implement the operations and complete the levels one by one, not altogether, keeping in mind that you will need to refactor to support additional functionality. Please, do not change the existing method signatures.
📂 Example Structure
[storage]
├── Client123
│ ├── 2024-02-10
│ │ ├── recording-a.mp4 (TTL: 7 days)
│ │ └── recording-b.wav (TTL: 30 days)
│ └── 2024-02-09
│ └── recording-c.mp4 (TTL: 7 days)
└── Client456
└── 2024-02-10
└── recording-d.mp4 (TTL: 14 days)
🚀 Phase 1 — Initial Design & Basic Functions
STORE_RECORDING(client_id, recording_name, date, size, ttl_days)
- Store the recording in the format
{client_id}/{current_date}/{recording_name} - Associates the specified TTL (in days) with the recording
- If a recording with the same path already exists, throw a
RuntimeError
GET_RECORDING(client_id, recording_name, date)
- Returns metadata (size, remaining TTL) if it exists and hasn’t expired
- Returns nothing if the recording doesn’t exist or has expired
COPY_RECORDING(source_path, dest_path)
- Copy to a new location, maintaining TTL
- Throws exception if expired or non-existent
⚙️ Phase 2 — Recording Ownership & Metadata
GET_RECORDING_OWNERSHIP(recording_name)
- Returns a tuple
(client_id, date) - Must handle expired and missing recordings with exceptions
🧭 Phase 3 — Version History & Rollback
ROLLBACK(timestamp)
- Roll back storage state to the specified time
- Must recalculate TTLs based on original creation date
- Restore deleted recordings, remove later-added ones
- Handle partial failures gracefully
🧩 我们在 CSOAHelp 的实战解法
如果你刚拿到这题,很容易一眼懵——
这其实不是“普通算法”,而是一个 迷你分布式存储系统。
难点在于:
- 需要理解 TTL 的动态衰减逻辑
- 设计层次清晰的数据结构(嵌套 dict)
- 持续重构以支持 Phase 2、3 的附加功能
- 正确抛出异常类型(例如 RecordingNotFoundException / ExpiredRecordingException)
- 保证 rollback 的一致性与性能
我们的辅导老师在第一时间建立了正确的类结构:
class StorageService:
def store_recording(self, client_id, recording_name, date, size, ttl_days): ...
def get_recording(self, client_id, recording_name, date): ...
def copy_recording(self, source_path, dest_path): ...
def get_recording_ownership(self, recording_name): ...
def rollback(self, timestamp): ...
并逐阶段实现功能,每次提交都通过系统的全部测试用例

🚀 想在 OA 阶段直接拿高分?我们能帮你做到
在 CSOAHelp,我们提供:
- 🧩 实时 OA 解题指导(
- 💻 全代码模板(Python / C++ / Java)
- 📚 面试前复盘讲义,还原每个关键环节考点
无论是 Salient / Bloomberg / Palantir / Citadel / Amazon OA,我们都能帮你一步步拆解,通过全测,拿满分。
我们长期稳定承接各大科技公司的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。
We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.

