Ebay Interview Question
Java DevelopersCountry: United States
Interview Type: In-Person
That doesn't seem to work. What if last download reset happened 24h ago (as well as the first download) and 8 more downloads occurred in the last hour. Next download, say, in the next hour causes the reset timestamp as well as counter get updated. So, now we could start 9 more downloads, which gives us 18 downloads for the last 2 hours.
You need to keep a list (in a separate table) of all 10 downloads (timestamps) for a user, so that you could easily get and update the earliest and the latest downloads for the user.
Lets say we have a database table with below columns:
UserID, lastDownloadresetDateTime, lastDownloadDateTime, downloadCount.
lastDownloadresetDateTime would store the datetime when user tries to download something and the lastDownloadedDateTime > 24hrs.
That is: pseudo logic
- Mohan December 21, 2015