Rubrik: Logical memory unit that caches page entries and returns the k most recent
Problem. Build a logical memory layer that sits between a CPU and physical memory. The CPU asks for a page by its pageId. If the logical unit already holds that page, return it; if not, load it from physical memory and keep the entry.
Required operations
- Request a page by id (hit returns from the logical unit, miss falls through to physical memory).
- Keep every entry recorded for a page inside the logical unit.
- Return the latest entry for a page, or the k latest entries for that page.
What the candidate did. A map from page id to a linked list holding that page's entries, so the newest items sit at the head and the k most recent can be read off quickly.
Follow-up. Once the single-threaded version worked, the interviewer asked how to make it safe when many threads call it at once.
What mattered. This was a system-coding round rather than a pure algorithms round: a complete, running solution, checked against several test inputs, plus a sound answer on locking and concurrent access.
Comments 0
No comments yet. Ask the author something, or add what happened in your own round.