← 返回 sofi 的题目列表Key-Value Store with getLast
类型:qbank
Design and implement an in-memory key-value store supporting add, get, remove, and getLast, where get does not update recency.
Requirements
Implement a key-value store.
Required operations: get, add, remove, and getLast.
Calling get(key) must not change the getLast result.
Use hashmap plus linked-list style bookkeeping to support efficient lookup and last-item retrieval.
Follow-up: discuss how to scale across multiple servers, including consistent hashing or partitioning.
Notes
Clarify whether getLast means most recently added, most recently updated, or last remaining insertion-order key.
remove must update both the hashmap and linked structure.