Amazon Interview Question for Developer Program Engineers


Country: India
Interview Type: Phone Interview




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

In database table (and corresponding class) holding user info, a field of incorrect_attempts_count is declared.

A thread (say login thread) monitors this class/table and When the incorrect attempts are made by user it increments the count.

A Queue (underlying implemenation using LinkedList ) is maintained where each node of queue contains 2 feilds as
Struct Node
{
unsigned int userid;
datetime timeInserted;
}

When user does 5 consecutive incorrect attempts a node having user id and current time info is inserted into Queue.

A timer thread runs every minute and peeps into the front-end of Queue. If currenttime -Insertion time < 1 Hr it leaves queue as it is. Otherwise it keeps on removing the nodes until it finds a node whose duration is < 1 Hr or it hits the front of the list.

Now for all the removed nodes,
1. It can only set the incorrect_attempt_count_to 0;
2. If timer is generic, post these nodes to different thread
3. on a good design note, user info class should have a thread function which can be signaled by this thread to reset its incorrect_attempt_count

The advantage of Queue is looking at the front node, we can confirm that all the nodes inserted after that have not exceeded 1 hour time limit (i.e. O(1) complexity)

- CSPrasad January 05, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Class User:
-usual name,password,address etc
-list_of_last_five_incorrect_login_times

- Ashu January 05, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

How would you find out if user is using same browser or not?

- Shekhar January 05, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

the answer 2 to me seems like every browser has its own session..so even if the user tries to log in via some different browser it shouldn't be an issue since we are handling it on the server side.

- Nikhil February 13, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

the answer 2 to me seems like every browser has its own session..so even if the user tries to log in via some different browser it shouldn't be an issue since we are handling it on the server side.

- Nikhil February 13, 2012 | Flag Reply


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