最近刚做完 Persona OA ,整体体验和传统 leetcode 算法题完全不一样,更像是 OOD + 系统设计简化版的实现,代码量大但思路清晰就能稳稳过。整个 OA 在 Codesignal 平台,时长 90 分钟 4 道题,而且要注意:必须完成一个 level 才能解锁下一个 level,不能跳题。
我之前刷过 Meta、Circle、Coinbase 的 OA,这几家题型都类似,比较偏场景设计和面向对象,和纯刷 leetcode 的感觉完全不同。
Persona OA 题目回忆
这套 Persona 的 OA 是分等级解锁的,一共 4 个 level,每一关都是在前一关的基础上扩展。
Level 1 – Basic File Operations
Implement a simple in-memory cloud storage system with support for basic file operations:
add_file(name: str, size: int) -> bool
Add a new file with the given name and size. Return True if the file was added successfully, or False if a file with the same name already exists.
copy_file(name_from: str, name_to: str) -> bool
Copy an existing file to a new file. The operation should fail if the source file does not exist, or if the target file already exists. Ownership of the copied file is preserved.
get_file_size(name: str) -> Optional[int]
Return the size of the given file if it exists, otherwise return None.
核心就是实现一个文件字典,支持新增、复制、查询大小,同时保证边界条件正确。
Level 2 – File Search by Prefix and Suffix
Extend the storage system with search functionality:
find_by_prefix(prefix: str) -> List[str]
Return a list of all files whose names start with the given prefix.
find_by_suffix(suffix: str) -> List[str]
Return a list of all files whose names end with the given suffix.
考点主要是字符串匹配,能用简单遍历过就行,不要求最高效,但要考虑多个文件、空结果等情况。
Level 3 – User Management and Quotas
Introduce user accounts with storage capacity limits. All users share the same file system, but each has an individual quota.
add_user(user_id: str, capacity: int) -> bool
Add a new user with the given capacity (bytes). Return False if the user already exists.
add_file_by(user_id: str, name: str, size: int) -> Optional[int]
Add a new file owned by the given user. The operation fails if the user does not exist, if the file name already exists, or if adding the file would exceed the user’s quota. On success, return the remaining capacity for that user.
update_capacity(user_id: str, capacity: int) -> Optional[int]
Update the quota for the user. If the user’s total storage exceeds the new quota, remove files until usage fits the quota. Removal policy: delete the largest files first, and if sizes are equal, remove files with lexicographically larger names first. Return the number of files removed, or None if the user does not exist.
这里是最复杂的一关,需要维护文件归属、容量计算,还要写清楚删除文件的排序逻辑。
Level 4 – Compression and Decompression
Finally, support compressing and decompressing files.
compress_file(name: str) -> bool
Compress the given file. Its size should be reduced (e.g., halved or encoded in some way). Return False if the file does not exist or is already compressed.
decompress_file(name: str) -> bool
Restore the file back to its original size. Return False if the file does not exist or is not currently compressed.
实现方式可以比较灵活,不需要真正写压缩算法,只要能在逻辑上区分“压缩”和“解压”,并保证文件大小能恢复即可。
总结
Persona OA 不是纯粹的算法题,而是 面向对象 + 系统设计的落地实现。如果你只刷 leetcode,第一次遇到可能会慌,但只要提前看过类似的题型(Meta、Coinbase 那种 OOD OA),就会觉得套路差不多。
这类题型更考验的是:
- 需求拆解能力
- API 设计思路
- 数据结构组织
- 边界情况处理
准备时可以多刷几套 Codesignal 平台 OOD 风格的 OA,熟悉之后就能在考试时 90 分钟 4 题稳稳通过。
OA 太难?我们团队全程带飞,不卡壳不掉链子!
像 Persona 这种 OOD + 大项目风格的 OA,很多同学第一次遇到容易慌乱,逻辑没拆清楚就写崩了。我们团队长期提供 OA 全程辅助:
远程无痕联机,保证所有 test case 100% 通过
实时语音提醒,卡点时帮你捋清思路
面试场景下还能补充思路点拨,确保不卡壳
如果你也在准备 Persona、Meta、Coinbase 这类 OOD 风格的 OA/面试,可以随时来找我们聊聊。帮你把复杂的大题拆解到位,关键时刻不掉链子。