Reported September 2026
Blinkitdesign

LRU Cache

Reported by candidates from Blinkit's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Blinkit OA. Under 2s to a working solution.
Founder's read

With up to 200000 operations and a capacity up to 100000, the Blinkit LRU Cache question reported in September 2026 punishes anything that scans the cache on each call. It's a design problem, and the trick is the classic one: a hash map plus a doubly linked list so every GET and PUT runs in O(1). You've probably seen the LeetCode version, but this one wraps it in a string-parsing function that returns the GET results. If you blank on the pointer wiring during the live OA, StealthCoder is the safety net running invisibly on your screen.

The problem

Implement a least recently used cache with fixed positive capacity, then process the operations in operations.
"PUT key value" inserts or updates a key. When a new key would exceed capacity, evict the least recently used key.
"GET key" returns the stored value, or -1 when the key is absent.
A successful GET and every PUT make that key the most recently used. A missing GET does not change recency. Return the results of all GET operations in their original order.
Build the cache behavior directly; do not use a library-provided LRU cache.

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]
GET 1 makes key 1 recent, so inserting key 3 evicts key 2.
Example 2
capacity = 1
operations = ["PUT 4 7","PUT 4 9","GET 4","PUT 5 5","GET 4"]
return = [9,-1]
Updating key 4 changes its value to 9. Inserting key 5 later evicts it because capacity is 1.
Example 3
capacity = 2
operations = ["GET 7","PUT 0 0","GET 0"]
return = [-1,0]
The first lookup misses without changing the cache. Keys and values may be zero.

Constraints
1 <= capacity <= 100000.
1 <= operations.length <= 200000.
Every operation is exactly "GET key" or "PUT key value".
-10^9 <= key, value <= 10^9.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Brute force fails fast. A list or array that searches for the key and shifts elements costs O(capacity) per operation, and 200000 operations times 100000 slots is far too slow. The fix is a hash map from key to node, plus a doubly linked list ordered by recency. On a successful GET or any PUT, unlink the node and move it to the front. On a new PUT that exceeds capacity, drop the tail node and delete its key from the map. Common pitfalls: forgetting that updating an existing key must not evict anything, moving a node on a missing GET (it shouldn't), and mishandling key 0 or value 0 or negative numbers. Use dummy head and tail nodes to kill edge cases. Parse each operation by splitting on spaces. If the pointer logic slips under pressure, StealthCoder can cover you during the live OA.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill LRU 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. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as lru cache. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Blinkit's OA.

Blinkit reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

LRU Cache FAQ

What's the trick to the Blinkit LRU Cache problem?+

Pair a hash map with a doubly linked list. The map gives O(1) lookup of a node by key. The list keeps recency order, with the most recent at the front and the least recent at the tail. Every move and eviction is then constant time, which the 200000 operation limit demands.

Can I use LinkedHashMap or OrderedDict?+

No. The problem says to build the cache behavior directly and not use a library-provided LRU cache. Using an ordered map that does the recency work for you risks failing the spirit of the rules. Write your own node class and manage the pointers yourself.

What edge cases break most solutions?+

Updating an existing key when the cache is full, which must not evict anything. A missing GET must not change recency. Capacity of 1 is another trap. Keys and values can be 0 or negative, so don't use 0 as a sentinel for absent. Return -1 explicitly.

How do I parse the operations array?+

Split each string on a space. If the first token is GET, read one integer key. If it's PUT, read the key and value. Append the result of each GET to an output list in order, then convert it to an int array at the end.

How do I prepare for this in 48 hours?+

Write the LRU cache from scratch twice without looking. Use dummy head and tail nodes, and write helper functions for remove and add-to-front. Then test Example 2 by hand, since capacity 1 with an update exposes most bugs. Once the helpers are right, the rest is short.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Blinkit.

OA at Blinkit?
Invisible during screen share
Get it