Ebay Interview Question for Java Developers


Country: United States
Interview Type: In-Person




Comment hidden because of low score. Click to expand.
0
of 0 vote

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

if (lastDownloadresetDateTime - currentDateTime < 24 hrs AND downloadCount == 10)
{
	// deny access for downloading
}
else
{
	// allow download access and set the below values for the user
	if (lastDownloadresetDateTime - currentDateTime > 24 hours)
	{
		update lastDownloadresetDateTime = currentDateTime 
		update downloadCount = 1;
	}
	else
	{
		update downloadCount++;
	}
}

- Mohan December 21, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

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.

- Alex M. February 02, 2017 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More