Persona OA 面經分享 | Codesignal 90 分鐘 4 題全解析

最近剛做完 Persona OA ,整體體驗和傳統 leetcode 演算法題完全不一樣,更像是 OOD + 系統設計簡化版的實現,代碼量大但思路清晰就能穩穩過。 整個 OA 在 Codesignal 平臺,時長 90 分鐘 4 道題,而且要注意:必須完成一個 level 才能解鎖下一個 level,不能跳題。

我之前刷過 Meta、Circle、Coinbase 的 OA,這幾家題型都類似,比較偏場景設計和面向物件,和純刷 leetcode 的感覺完全不同。

Persona OA

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 copiedfile 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 theuser’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/面試,可以隨時來找我們聊聊。 幫你把複雜的大題拆解到位,關鍵時刻不掉鏈子。

author avatar
jor jor
END
 0
Comment(尚無留言)