Least Recently Used Cache
Reported by candidates from Illumio's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Illumio reported this one in August 2026, and the input size is the whole story. With up to 200000 operations and a capacity up to 200000, any approach that scans the cache to find the oldest key will time out. This is the classic LRU cache wrapped in a string-parsing function, so you parse each operation and run it in O(1). If you've seen the design pattern, you're fine. If you blank on the linked list wiring, StealthCoder is the safety net that runs invisibly during the live OA and hands you the structure.
The problem
Process a finite ordered sequence of operations on a least recently used cache with capacity capacity. PUT key value inserts or updates key. A successful write makes that key the most recently used. If inserting a new key would exceed the capacity, first evict the least recently used key. GET key returns the stored value, or -1 when the key is absent. A successful lookup makes the key the most recently used; a missing lookup does not change the cache. Return the integer results of the GET operations in encounter order. A PUT operation produces no result. Every operation uses decimal integers separated by one space. Function runLRU(capacity: int, operations: String[]) → int[] Examples Example 1 capacity = 2 operations = ["PUT 1 10","PUT 2 20","GET 1","PUT 3 30","GET 2","GET 3"] return = [10,-1,30] Reading key 1 makes it the most recently used entry, so inserting key 3 evicts key 2. Example 2 capacity = 1 operations = ["PUT 5 7","PUT 5 9","GET 5","PUT 6 4","GET 5"] return = [9,-1] Updating key 5 replaces its value without increasing the cache size. Inserting key 6 later evicts it. Example 3 capacity = 3 operations = ["GET 8","PUT 8 0","GET 8"] return = [-1,0] The first lookup misses. After the insertion, the stored value 0 is returned normally. Constraints 1 <= capacity <= 200000. 1 <= operations.length <= 200000. Every operation is exactly GET key or PUT key value. 0 <= key, value <= 10^9.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is a hash map from key to node plus a doubly linked list ordered by recency. GET moves the node to the front and returns the value, or -1 if missing with no change. PUT updates the value and moves the node to the front, or inserts a new node at the front and evicts the tail if size exceeds capacity. Every step is O(1), so 200000 operations is trivial. Pitfalls: a failed GET must not touch order, updating an existing key must not trigger eviction (Example 2), and value 0 is a valid result, so don't treat it as falsy. Parse each string by splitting on spaces and converting to integers. Use sentinel head and tail nodes to dodge null checks. In some languages an ordered hash map does the job in a few lines. If the pointer logic slips under pressure, StealthCoder is the hedge during the live OA.
Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.
You can drill Least Recently Used Cache cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as lru cache. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Illumio's OA.
Illumio reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Least Recently Used Cache FAQ
How hard is the Illumio LRU cache question really?+
It's a medium that feels hard only if you've never wired a doubly linked list with a hash map. The logic is short once you know it. The extra layer here is parsing operation strings, which is easy but easy to fumble under time pressure.
What's the trick to passing the large inputs?+
Get O(1) for both GET and PUT. A hash map finds the node instantly, and a doubly linked list lets you move it to the front or drop the tail without scanning. Anything that searches for the oldest key will fail at 200000 operations.
Which edge cases break most solutions?+
Updating an existing key must not evict anything. A missing GET must not change order. Value 0 is legitimate, so don't use truthiness checks. Capacity 1 is also worth testing mentally, since every new key evicts the previous one.
Can I use a built-in ordered map instead of writing a linked list?+
Often yes. Python's OrderedDict or Java's LinkedHashMap with access order gives you move-to-end and pop-oldest in O(1). Check that your language's version supports both. If you're unsure, writing the manual list is safer and not much longer.
How do I prepare for this in 48 hours?+
Write the LRU cache from scratch twice without looking. Use sentinel head and tail nodes. Then add the string parsing wrapper and run the three examples from the problem. That covers the whole question, and it takes about an hour.