Instacart software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.
No verified questions yet for Instacart.
as_of selects the mutation with the greatest timestamp less than or equal to as_of. Return None if no such mutation exists or if the selected mutation is a deletion.timestamp with ttl_seconds = t is visible only while as_of < timestamp + t. An expired selected version returns None; never fall back to an older version. A missing TTL means no expiration. A quantity of zero is still a valid, retrievable product version.RetailerCatalogHistory() — construct an empty store.set_product(retailer_id: str, sku: str, timestamp: int, price_cents: int, quantity: int, ttl_seconds: Optional[int] = None) -> None — insert or replace a timestamped product version.delete_product(retailer_id: str, sku: str, timestamp: int) -> None — insert or replace a timestamped deletion, including for a previously unknown product.get_product(retailer_id: str, sku: str, as_of: int) -> Optional[ProductSnapshot] — retrieve the visible version at the requested time.list_available(retailer_id: str, as_of: int) -> List[ProductSnapshot] — retrieve visible, positive-quantity products in SKU order.ProductSnapshot has typed fields sku: str, price_cents: int, and quantity: int.catalog = RetailerCatalogHistory()
catalog.set_product("r1", "milk", 10, 499, 6)
catalog.set_product("r1", "milk", 20, 549, 2, 5)
catalog.get_product("r1", "milk", 19)
catalog.get_product("r1", "milk", 24)
catalog.get_product("r1", "milk", 25)
catalog.get_product("r1", "milk", 9)[
{"sku": "milk", "price_cents": 499, "quantity": 6},
{"sku": "milk", "price_cents": 549, "quantity": 2},
null,
null
]20 + 5 = 25, so the lookup at 25 returns null without reviving the version at 10. No version exists at time 9.Example 2:catalog = RetailerCatalogHistory()
catalog.set_product("r1", "milk", 10, 499, 6)
catalog.delete_product("r1", "milk", 30)
catalog.set_product("r1", "milk", 20, 529, 3)
catalog.set_product("r1", "apples", 15, 199, 4)
catalog.set_product("r1", "bread", 15, 399, 0)
catalog.set_product("r2", "milk", 10, 459, 8)
catalog.list_available("r1", 25)
catalog.get_product("r1", "milk", 35)
catalog.set_product("r1", "milk", 30, 559, 1)
catalog.list_available("r1", 35)
catalog.get_product("r2", "milk", 35)[
[
{"sku": "apples", "price_cents": 199, "quantity": 4},
{"sku": "milk", "price_cents": 529, "quantity": 3}
],
null,
[
{"sku": "apples", "price_cents": 199, "quantity": 4},
{"sku": "milk", "price_cents": 559, "quantity": 1}
],
{"sku": "milk", "price_cents": 459, "quantity": 8}
]r2 is independent.Constraints[0, 10^12]; prices and quantities are integers in [0, 10^9]; TTL is either absent or an integer in [1, 10^9].Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free