camiloa136
BAN USER- 1of 1 vote
AnswersA new Kindle feature is being developed to rank customers based on their reading speed.
- camiloa136 in Vancouver
A customer's "reading speed" is the maximum number of pages they have read in a single minute over the previous 10 minutes. Every minute, we will log the customer's current page, which can be used to calculate this speed. For example:
Current Time: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15]
Current Page: [0, 5, 6, 8,12,15,17,21,24,27,29,31,37,42,49,52]
Current Speed: [0, 5, 1, 2, 4, 3, 2, 4, 3, 3, 2, 2, 6, 5, 7, 3]
"Reading Speed": [0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 6, 6, 7, 7]
We want to produce separate leaderboards for each book. Each customer will only read one book at a time, but multiple customers may read the same book.
Every minute, the "updateReadingSpeeds" method will be called to report each customer's reading progress. Please implement this method:
void updateReadingSpeeds(String customerID, String bookID, int pageNumber)
At any time, we should be able to request the full leaderboard for any book. Please implement the "printLeaderboard" method:
void printLeaderboard(String bookID)
The output should be CSV printed to standard output, like:
Customer ID,Reading Speed,Rank
Customer 1,5,1
Customer 3,4,2
Customer 2,4,3
Customer 5,2,4
*The updateReadingSpeeds method will be called every minute for every customer.
*CustomerID will uniquely identify a customer, bookID will uniquely identify a book
*Page numbers are integers between 0 and 1000000, and will never decrease over time.
*Customers who "tie" with the same reading speed can be ranked in any order.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm