Confirm the role
typicalRead the exact opening and identify the role of Inventory consistency in its responsibilities. Write down confirmed requirements separately from assumptions about the company.
Attempt the fundamentals
typicalBegin with implement an lru catalog cache and reserve stock without overselling. State the contract aloud, then preserve the test case or diagram that exposed your first gap.
Work through failure cases
typicalUse the worked solutions to connect cache semantics to a concrete outcome. Change one assumption, explain what breaks and verify the revised result.
Explain and review
typicalRehearse one project decision and a timed technical answer. Ask the interviewer which constraints matter before optimizing; use feedback to revise the weakest explanation.
Choose a category, try a prompt, then open its approach, worked solution or follow-up when you need it.
Implement an LRU catalog cache
Implement a capacity-bounded least-recently-used cache. A successful get and an update both make a key most recent; capacity zero stores nothing.
Approach
- Maintain a map plus recency order so lookup, insertion and moving a key are efficient. A doubly linked list is a language-independent design; an ordered dictionary is a concise reference implementation. State whether missing values use a sentinel or an exception.
- When updating an existing key, replace its value and move it to the most-recent end without increasing logical size. After insertion, evict the oldest key only when over capacity. Test an update before eviction because it catches many stale-order bugs.
- LRU is not a freshness guarantee. Inventory and price changes need invalidation or version checks, and checkout must use authoritative availability. Discuss memory limits, concurrency and oversized entries separately from entry count; the interview implementation is deliberately single-process.
Worked solution 40 min
Evict the least recently used key
With capacity two: put a, put b, get a, then put c. Determine which key is evicted.
- Insertion puts a then b in oldest-to-newest order. Getting a makes b the oldest. Inserting c exceeds capacity, so b is removed.
- Updating an existing key must also move it to the newest position. Use an ordered mapping for a compact Python reference, but explain the map-plus-linked-list equivalent if library containers are disallowed.
- Capacity zero accepts calls but stores no entries. Missing keys raise KeyError, so a cached None can still be distinguished from absence. The object is not thread-safe; a real shared cache requires a separate concurrency contract.
from collections import OrderedDict
class LRU:
def __init__(self, capacity):
if capacity < 0:
raise ValueError("negative capacity")
self.capacity = capacity
self.data = OrderedDict()
def get(self, key):
value = self.data[key]
self.data.move_to_end(key)
return value
def put(self, key, value):
self.data[key] = value
self.data.move_to_end(key)
if len(self.data) > self.capacity:
self.data.popitem(last=False)Scroll sideways to view long lines.
Follow-up
- How would you combine expiration with recency?
- Why must cached availability not authorize a sale?
Aggregate repeated item updates
Aggregate signed quantity deltas by (location, SKU), retaining first-seen key order. Explain validation and replay assumptions.
Approach
- Use a hash map keyed by both location and SKU. A SKU-only key would merge independent stock pools. Sum each accepted delta once, retaining the first appearance if deterministic output order is part of the contract.
- Clarify whether duplicate input rows are distinct business events or transport retries. Aggregating blindly is correct only after the input has been deduplicated where needed. Validate required keys and integer quantities at the boundary; do not silently coerce malformed records.
- The pass is O(n) expected time and O(u) space for u distinct keys. For unbounded streams, define a window or external state store. A negative net delta is valid for this exercise and does not by itself establish that physical stock is negative.
Worked solution 40 min
Aggregate deltas with scoped keys
Aggregate (L1,A,+3), (L2,A,+2), (L1,A,-1) after event deduplication.
- The keys are (L1,A) and (L2,A). The final delta for L1/A is two, while L2/A remains two. A SKU-only dictionary would incorrectly combine the two locations.
- Insertion-ordered dictionaries retain first-seen key order in modern Python. Updating a key does not move it, matching the contract. Return explicit triples so the composite identity remains visible to the caller.
- Treat the input as validated, deduplicated event deltas. This function does not check an event ID and must not be presented as safe under replay by itself. For large streams, move the same aggregation contract into a bounded window or durable stateful processor.
def aggregate(rows):
totals = {}
for location, sku, delta in rows:
key = (location, sku)
totals[key] = totals.get(key, 0) + delta
return [(loc, sku, total) for (loc, sku), total in totals.items()]Scroll sideways to view long lines.
Follow-up
- How would you add event-ID deduplication?
- What changes when input exceeds memory?
Reserve stock without overselling
Design an atomic reservation for a quantity at one fulfillment center. Reject insufficient stock and make retried requests return the same reservation.
Approach
- Define the invariant available equals on_hand minus reserved and cannot become negative. Scope stock to location and SKU. A displayed catalog count is a read model; checkout must arbitrate against the authoritative state.
- Use a conditional update inside a transaction, plus a uniquely keyed reservation record. A separate read-then-write is vulnerable to two buyers observing the same last unit. The request key and quantity must be compared on retry so reuse cannot silently change the order.
- Model confirmation, cancellation and expiration as guarded state transitions. Release reserved stock once when the reservation moves from active to released. Coordinate payment failures explicitly, and use reconciliation to detect differences between physical and logical inventory.
Worked solution 40 min
Use a conditional stock update
A stock row has on_hand=3 and reserved=1. Request two additional units, then try one more.
- The first conditional update finds two available units and increments reserved to three. The next request cannot satisfy reserved+1 <= on_hand, so it updates zero rows.
- Check affected-row count to distinguish acceptance from rejection. Keep the reservation record insert and update in one transaction. The snippet demonstrates only the stock guard; a full implementation must also handle durable request identity, quantities greater than zero and expiration.
- Two independent read-then-write operations are not equivalent to this guarded write. In the target database, verify concurrent behavior at the chosen isolation level and retry transaction failures as whole operations. The runnable fixture is SQLite; it is not a production load test.
CREATE TABLE stock (
location TEXT NOT NULL,
sku TEXT NOT NULL,
on_hand INTEGER NOT NULL CHECK(on_hand >= 0),
reserved INTEGER NOT NULL CHECK(reserved >= 0 AND reserved <= on_hand),
PRIMARY KEY(location, sku)
);
INSERT INTO stock VALUES ('L1','S1',3,1);
UPDATE stock SET reserved = reserved + 2
WHERE location='L1' AND sku='S1'
AND reserved + 2 <= on_hand;Scroll sideways to view long lines.
Follow-up
- How do payment success and reservation expiration race?
- What changes for a cart with several SKUs?
Propagate inventory changes
Design an inventory update flow from multiple fulfillment centers to a customer-facing availability view.
Approach
- Keep one authoritative writer or concurrency rule for each location/SKU and emit versioned changes after committing state. A transactional outbox can connect the state write to eventual event delivery without assuming two independent writes always succeed together.
- Consumers should deduplicate event identities and reject stale versions. Decide whether events carry deltas or snapshots: a missing delta can corrupt a count, while a later snapshot can repair a read model. Use a replayable stream and reconciliation checkpoints.
- Expose freshness and degradation deliberately. During a partition, an availability view may lag while the reservation path still checks authoritative stock. Measure event lag, rejected stale updates and reconciliation discrepancies, not only broker throughput.
Follow-up
- How would a consumer detect a missing update?
- When would you rebuild a read model from snapshots?
Extract a service incrementally
Plan a gradual extraction of catalog reads from a monolith while checkout remains operational.
Approach
- Identify data ownership and callers before choosing deployment boundaries. Catalog reads may tolerate a materialized view while checkout needs authoritative state. Define which service can write each field so an extraction does not create two competing sources of truth.
- Introduce a stable interface, shadow a representative read path and compare results before switching traffic. Plan rollback and schema compatibility. Shadowing writes is dangerous if it causes duplicate side effects, so separate read comparison from mutations.
- Measure the operational cost of the new boundary: timeouts, retries, deployment coordination and on-call ownership. Extract only when the team can support the failure modes. A staged migration with clear acceptance checks is stronger than proposing a complete rewrite.
Follow-up
- What would stop the rollout?
- How would old and new clients coexist during schema changes?
Reproduce a concurrency failure
Two checkout requests occasionally reserve the final unit. Explain how to reproduce, diagnose and repair the race.
Approach
- Write the invariant and the two operations as an interleaving. Both read available=1, both pass validation and both write a reservation. A deterministic barrier between read and write can reproduce a bug that random stress tests miss.
- Inspect transaction boundaries, conditional updates and unique request constraints. A process-local lock is insufficient when several workers write the same stock. Use the database or another authoritative coordination mechanism to arbitrate the shared resource.
- Validate the fix with simultaneous attempts and crash/retry cases. Exactly one request should obtain the last unit; the other receives a defined rejection, and an identical retry does not create another reservation. Monitor rejected conflicts separately from unexpected failures.
Follow-up
- Which logs would prove the interleaving without exposing payment details?
- Can a retry introduce another race after the first bug is fixed?
Allow about one hour per session and move time toward the actual assessment. This is an editorial learning schedule, not the length of the hiring process.
Build the foundations
Code, query and define your contracts.
0 / 7 done01Map the actual role60 min
- Read the official company resource and the specific vacancy.
- List unknowns about interview format and tools.
Deliverable: A role brief separating stated requirements from assumptions
02Implement an LRU catalog cache60 min
- Attempt the prompt before reading its approach.
- Explain one boundary case and answer its follow-up.
Deliverable: A written answer with a concrete example and one corrected assumption
Practice prompt ↗03Reserve stock without overselling60 min
- Attempt the prompt before reading its approach.
- Explain one boundary case and answer its follow-up.
Deliverable: A written answer with a concrete example and one corrected assumption
Practice prompt ↗04Propagate inventory changes60 min
- Attempt the prompt before reading its approach.
- Explain one boundary case and answer its follow-up.
Deliverable: A written answer with a concrete example and one corrected assumption
Practice prompt ↗05Aggregate repeated item updates60 min
- Attempt the prompt before reading its approach.
- Explain one boundary case and answer its follow-up.
Deliverable: A written answer with a concrete example and one corrected assumption
Practice prompt ↗06Reproduce a concurrency failure60 min
- Attempt the prompt before reading its approach.
- Explain one boundary case and answer its follow-up.
Deliverable: A written answer with a concrete example and one corrected assumption
Practice prompt ↗07Extract a service incrementally60 min
- Attempt the prompt before reading its approach.
- Explain one boundary case and answer its follow-up.
Deliverable: A written answer with a concrete example and one corrected assumption
Practice prompt ↗Connect & rehearse
Design, explain and revise with evidence.
0 / 7 done08Evict the least recently used key60 min
- Complete the worked exercise independently.
- Run or manually trace its checks and compare with the expected result.
Deliverable: An implementation or decision diagram plus recorded checks
Practice prompt ↗Worked solution ↗09Use a conditional stock update60 min
- Complete the worked exercise independently.
- Run or manually trace its checks and compare with the expected result.
Deliverable: An implementation or decision diagram plus recorded checks
Practice prompt ↗Worked solution ↗10Aggregate deltas with scoped keys60 min
- Complete the worked exercise independently.
- Run or manually trace its checks and compare with the expected result.
Deliverable: An implementation or decision diagram plus recorded checks
Practice prompt ↗Worked solution ↗11Connect the boundaries60 min
- Draw the user request, state owner and one failure path.
- Explain where retries, ordering or lifetime assumptions could fail.
Deliverable: An annotated workflow with a recovery check
12Prepare an evidence-based story60 min
- Choose an actual project relevant to the role.
- Explain your decision, a rejected option and feedback that changed it.
Deliverable: A two-minute story with an honest account of your contribution
13Run a timed mock60 min
- Pick one technical prompt and one follow-up.
- Record where you relied on an unstated assumption or could not explain a result.
Deliverable: A short list of specific gaps from the mock
Practice prompt ↗14Repair and consolidate60 min
- Redo the weakest exercise without looking at the answer.
- Prepare questions about ownership, review and success in this exact team.
Deliverable: A tested final attempt and three questions for the interviewer
Expand any day for tasks and deliverables. Your progress is saved on this device.
Connect your experience to Inventory consistency and Cache semantics. Use an actual example; do not turn the hypothetical exercises into claims about your work.
- 01
Describe a requirement you clarified before changing an implementation. What example resolved the ambiguity?
- 02
Explain a tradeoff where correctness or maintainability changed your first approach. What did you test?
- 03
Describe feedback that changed your design. Identify your own action and what you would do differently now.
Are these confirmed Gopuff interview questions?
The topics were selected from a third-party company guide. PracHub wrote the clarified exercises, solution approaches and follow-ups. Their presence in that source is not independent confirmation of what a current interviewer will ask.
Dataford: Gopuff Software Engineer guide ↗What interview rounds should I expect?
The available evidence does not establish a verified team-specific sequence. Ask about screening, practical assessments, project discussions, tool rules and evaluation criteria for your actual opening. The visual checkpoints here describe preparation activities.
Must I use the language in the worked example?
Use the assessment language when specified. The reference snippets make a contract easy to test; they do not establish the employer stack. Explain how the same invariant maps to your chosen language, library and database.
How should I use the practice cards?
Choose a category, attempt the prompt and then open the approach. For a worked solution, compare both output and edge cases. Close it and try again with one changed requirement; recognition alone is not a reliable sign of understanding.
What should I prioritize with only a weekend?
Work through implement an lru catalog cache, attempt evict the least recently used key and prepare one honest project story. Record the assumptions you cannot defend, then resolve those before expanding the topic list.
How does editorial practice differ from the PracHub question bank?
These exercises live within this guide and do not create company question-bank records. The main practice button uses the current available bank for the company or role. Its count is separate from the number of editorial prompts.
PracHub: Software Engineer questions ↗Sources & methodology 6 sources ↗
Official role evidence, timestamped platform data and clearly labeled preparation advice.
- 01Gopuff: official resource ↗
Business context: delivery of everyday essentials through fulfillment operations. This source is not used to invent interview rounds.
official · Accessed 2026-09-15 - 02Dataford: Gopuff Software Engineer guide ↗
Third-party source of selected topics; current employer attribution is not independently confirmed.
platform · Accessed 2026-09-15 - 03PracHub: Software Engineer questions ↗
Role-level practice destination; separate from editorial prompts.
platform · Accessed 2026-09-15 - 04Python collections ↗
Reference for ordered mappings and queue-based implementations.
official · Accessed 2026-09-15 - 05PostgreSQL: transaction isolation ↗
Understand concurrent-write behavior and whole-transaction retries.
official · Accessed 2026-09-15 - 06Google SRE: monitoring distributed systems ↗
Use latency, traffic, errors and saturation to guide investigation.
official · Accessed 2026-09-15