Marketplace Price War

10pts
e Bay, Amazon

Problem Statement

On eBay, price wars can occur when sellers use automated repricing tools. We want to identify sellers who are "reactively" lowering their prices.

A reactive price drop is defined as:

  1. Seller A (Competitor) lowers the price of Product X.
  2. Seller B (Subject) lowers the price of the same Product X within 10 minutes after Seller A change.
  3. Seller B and Seller A must be different sellers.

Write a query to find the list of sellers who have engaged in at least one such reactive price drop.

Rules:

  • A price drop is identified when the new_price is strictly less than the previous_price in the price_changes table.
  • The reaction must occur between 0 and 10 minutes (inclusive) after the competitor drop.
  • Output columns: seller_id, reactive_drops_count.
  • Result must be sorted by reactive_drops_count descending, then seller_id ascending.
Tests your understanding of
Self Joins, Time Series and Window Functions

Input Tables

price_changes
change_id(INTEGER)seller_id(INTEGER)product_id(INTEGER)previous_price(DECIMAL)new_price(DECIMAL)change_timestamp(TIMESTAMP)
1101100952026-03-04 10:00:00
2201100942026-03-04 10:05:00
310195902026-03-04 10:08:00
430250452026-03-04 11:00:00
540250442026-03-04 11:02:00
650250482026-03-04 11:20:00

Expected Output

seller_id(INTEGER)reactive_drops_count(INTEGER)
101
201
401

Tags

HardSelf JoinsTime SeriesWindow Functions
35-45 min
28%

Hints