Design a Price History Store With Point in Time Lookup

Last updated: November 29, 2026

Quick Overview

Build a structure that records price changes for each SKU with an effective timestamp and answers what the price of a SKU was at any given time. Corrections can arrive for past timestamps.

Walmart Labs
Coding & Algorithms
Software Engineer
Walmart Labs
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Build a structure that records price changes for each SKU with an effective timestamp and answers what the price of a SKU was at any given time. Corrections can arrive for past timestamps.

Walmart's pricing teams need point in time answers to resolve price match claims and audit rollbacks. The Walmart Labs technical screen uses this to test binary search on sorted timestamps and careful handling of out of order and same-timestamp updates.

What the Interviewer Expects
  • Keep per-SKU timestamps sorted
  • Use bisect_right minus one for the floor lookup
  • Handle a query before the first price
  • Treat a same-timestamp write as a correction
  • Discuss the cost of out of order inserts
Key Topics to Cover
binary search
design a data structure
time series
bisect
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you also answer the lowest price in the last 30 days?
  • How would you persist this so it survives restarts and scales to all SKUs?
  • What if each store has its own price for the same SKU?
  • How would you delete history older than a retention window?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

set_price(sku, price, ts) says the price became price at time ts and stays until the next change. price_at(sku, ts) returns the price in effect, or None if the SKU had no price yet. Writes mostl...

High-Level Design

Per SKU, keep two parallel lists: sorted timestamps and their prices. A lookup is a floor search: bisect_right(times, ts) - 1 gives the last change at or before ts. Writes use bisect_left to find ...


Submit Your Answer
Markdown supported