Amazon Interview Question
Developer Program EngineersCountry: India
Interview Type: Phone Interview
is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.
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.
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.
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.
In database table (and corresponding class) holding user info, a field of incorrect_attempts_count is declared.
- CSPrasad January 05, 2012A 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)