Amazon Interview Question for Software Engineer / Developers


Country: United States
Interview Type: Phone Interview




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

How bout a HashMap of LinkedLists wit the key being the user name and the linkedlist the dates the user logs in?

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

Linked list will have a linear look up time

- Anjana October 05, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

If we keep the latest time as head finding previous will be just one node behind. So linear lookup time wont bother us.

- code756 October 06, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

We dont have to store all the times when user logs in. We just need to store when he logged in last. A simple hashmap with user as key and last login as the value. This value will be changed everytime a user logs in and the value that it replaces is the last time user logged in.

- Illusion October 08, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

How about using stack instead of linked list. the information stored will be in order of dates.

- A Choudhary October 14, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Linear Look up time matters, if the user have logged in n times today and we are looking for previous day.

- Anjana October 29, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Also by previous date, doesn't it mean any previous dates?

- Anjana October 29, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

@illusion your solution will not work if the user logs in multiple times on the same day.

- hack October 31, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

@hack-- i think illusion's solution will work only if we have to give only the last time and date of sign in otherwise if you want all the dates then use hashmap which hashes to a linkedlist and then use head to get the latest date

- xian_7 November 07, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

For an application we are working on, here is a sample log file line:

Oct-02-2012 15:29:30+8 GMT, user id: jsmith logged in from xxx.xxx.xx.xx.

If the interviewer wants to "do one text search" to get to this line, we could modify it to:

Oct-02-2012 15:29:30+8 GMT, user id: jsmith(Oct-02-2012) logged in from xxx.xxx.xx.xx

Then you could search the log file by "userid(yesterday-date)" string.

- xdoer October 04, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

So then you will search the entire file every time? You can optimize this much better...

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

Why cant we use just a hashmap with key being calculated with a combination of userid and date. Assuming user id is unique.

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

You can...or just one hashmap per day, with the key just being the username

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

Question says only "previous date"
So we can have two hashtables - one for today, one for yesterday.
when user signs in, add his user name to todays' hashtable
at the beginning of a new day, replace yesterday with today and clear today
now to check if user logged in yesterday, just check his availability in yesterday's hashtable

- DarkKnight October 07, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

If just for one previous day, this would work fine. maybe a hashmap instead of hashtable.. we probably dont need a synchronization here.

- Jay October 30, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

You could maintain a hash table with each value storing a linked list of values
if we are fetching date based on username
Use key as username
if we are fetching username based on date
Use key as Date

- Rama Chandu October 10, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

use nested hashmaps

key             value
hashmap(username, hashmap2)

hashmap2(date,        time ? )

- hack October 31, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1) run a text match for previous date and extract user information
2)use a trie or ternary tries for storing only user names who logged in on the previous dates

- keshav January 01, 2013 | 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