Amazon onsite | Dec 2020 | SDE II
Anonymous User
1350

You recently joined Amazon to work in the deal team. The team is preparing to host a service that will allow anyone to get the top longest standing product prices.
Given access to the logs of price changes and the dates, help your team to deliver this api.

Example: (Log format: timestamp product_id new-price)

  • Today is 2020-12-03

    • 2020-10-18 product1 200
    • 2020-10-30 product1 100 -> 12 days at 200
    • 2020-11-04 product1 120 -> 5 days at 100
    • 2020-11-09 product1 150 -> 5 days at 120
    • 2020-11-15 product1 100 -> 6 days at 150
    • 2020-11-25 product1 110 -> 10 days at 100
  • (until today) -> 8 days at 110

Top standing price is 100
- > Explanation - 100 has been the price for 5+10 (15) days, 200 has been the price for 12 days

Comments (4)