Edd
BAN USER- 0of 0 votes
AnswersAt regular interval, we are receiving data (Price,Quantity). We need to find Most Sold Price(MSP). Need to design the solution to print the current MSP with total Qty of that price, every time a set of price and its quantity sold is provided as input.
Time Price Qty MSP(Total Qty) 11:01AM $10.01 100 $10.01(100) 11:03AM $11.01 200 $11.01(200) 11:04AM $12.81 150 $11.01(200) 11:06AM $10.01 210 $10.01(310) 11:07AM $10.01 180 $10.01(490) 11:08AM $12.81 400 $12.81(550) 11:09AM $11.01 200 $12.81(550)
In the interview, I wrote a solution using priority queue where each element of the priority queue is a tuple consisting of price and quantity. The priority queue arranges itself based on the quantity value of each tuple. When new value comes we access the tuple having the particular price, retrieve its quantity. Delete this tuple and insert a new tuple with the same price and updated quantity.
- Edd in United States
The interviewer was not satisfied with the solution and commented this is not how a large scale application will be build which is running throughout the day.| Report Duplicate | Flag | PURGE
Amazon Software Engineer Algorithm
This is my submitted code during the interview. In search of a faster algorithm.
- Edd November 29, 2015