最近刷到的 Ramp OA ,整體難度算中等,主要是實現一個簡化版的 Cloud Storage System,分三層難度,每層遞進,都要在規定時間內實現完整功能。 分享一下題目和我的感受。
OA 流程概覽
Ramp 的 OA 是在自家在线平台完成的,时长大约 90 分鐘,题目不是那种单纯的 LeetCode,而是更像系统设计的简化实现。从 文件操作 到 统计查询 再到 多用户场景,一层层增加难度。
真題內容
Level 1
The cloud storage system should support file manipulation.
add_file(self, name: str, size: int) -> bool— should add a new file name to the storage. size is the amount of memory required in bytes. The current operation fails if a file with the samename already exists. Returns True if the file was added successfully or False otherwise.get_file_size(self, name: str) -> int | None— should return the size of the file name if it exists, or None otherwise.delete_file(self, name: str) -> int | None— should delete the file name. Returns the deleted file size if the deletion was successful or None if the file does not exist.
Examples
add_file("/dir1/dir2/file.txt", 10) → True
add_file("/dir1/dir2/file.txt", 5) → False
get_file_size("/dir1/dir2/file.txt") → 10
delete_file("/non-existing.file") → None
delete_file("/dir1/dir2/file.txt") → 10
get_file_size("/not-existing.file") → None
Level 2
Implement an operation for retrieving some statistics about files with a specific prefix.
get_n_largest(self, prefix: str, n: int) -> list[str]— should return the list of strings representing the names of the top n largest files with names starting with prefix in the following format:["()", ..., "()"].
Sorting rules:
- By size (descending)
- If tie → lexicographical order
Examples
add_file("/dir/file1.txt", 5) → True
add_file("/dir/file2", 20) → True
add_file("/dir/deeper/file3.mov", 9) → True
get_n_largest("/dir", 2) → ["/dir/file2(20)", "/dir/deeper/file3.mov(9)"]
get_n_largest("/dir/file", 3) → ["/dir/file2(20)", "/dir/file1.txt(5)"]
add_file("/another_dir", "file.txt") → None (invalid input)
add_file("/big_file.mp4", 20) → True
get_n_largest("/", 2) → ["/big_file.mp4(20)", "/dir/file2(20)"]
Level 3
Implement support for queries from different users.
add_user(self, user_id: str, capacity: int) -> bool— add new user with storage limit. Fail if user already exists.add_file_by(self, user_id: str, name: str, size: int) -> int | None— similar to add_file, but restricted by user’s remaining capacity. Return remaining capacity if success, None otherwise.merge_user(self, user_id_1: str, user_id_2: str) -> int | None— merge user2 into user1: transfer files and add remaining capacity. Delete user2 after merge.
⚠️ Note: All queries calling the add_file from Level 1 are run by "admin" who has unlimited storage.
我的體驗
Ramp OA 不是單純的演算法題,更像是 考察代碼設計能力:
- Level 1 基礎,主要考查你是否能 clean code。
- Level 2 開始考察 排序+數據結構選擇,要保證複雜度。
- Level 3 更偏系統設計,需要考慮 多使用者限制、存儲管理、merge 邏輯。
我個人覺得難點是 設計數據結構,一開始要選好字典嵌套、還是類存儲,不然後面加功能會很麻煩。
你離 Offer 只有一步之遙 & Programhelp
這次 Ramp OA 我最後是靠提前刷過類似題型才比較順利。 如果你也即將面 Ramp 或類似 OA,想要更快更穩,其實可以考慮 Programhelp。
團隊有 Amazon、Google 工程師和牛津、清華學長,提供 OA 代寫、無痕連線助攻、VO 即時提示、面試類比 等服務。 比起單刷題,效率和通過率都會高很多。
聯繫我們,讓我們幫你一起搞定 OA,拿下理想的機會!