Amazon Interview Question for Development Support Engineers






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

1. take each line -> split it up with a delimiter and put it in a string array of 3[timestamp messagetype and message body ]
2. for each iteration check for index 1 for timestamp>3 pm and timestamp<5 pm
if true then move inside the loop
3. inside the loop compare the index 2 == with FATAL[do a findsubstring] , if matches then return the contents of this string array else continue with loop.


Space : 1 String Array with 3 indexes [we will overright each time]

Time Complexity : have to traverse all the log file hence O(N) atleast

- Tarun April 24, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

first of all we dont be able to load 50G of log file into memory. you could only load a portion of log file and check if that portion contains the log corresponding to 3 to 5 PM.

A log file with events will always be sorted according to time stamp in increasing order of only a single thread is writing to log file.

- Anonymous April 24, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Hi
It seems like you are in some program managerial role. If it is true then it's expected.

- Anonymous April 25, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Agree with tarun, however, it needs to be optimized. 50G of file may be on one disk or may spawn multiple disks based on the file structure. Also, reading each line means accessing disk so many times and will slow down the process. Assuming the program is running on a 4G RAM machine and assuming 2GB of RAM is available for the program, this can be completed in 25 disk accesses. However, one should also consider that this is not a guaranteed performance. Reading 2GB at a time may not read just 2GB in one shot. You may not have enough space in your stream buffers. You may not have enough paging memory left for other programs and this may altogether bring the system down. The solution is a best approximation of all parameters.

- Kiran April 26, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Each record contains a timestamp , message type and message body . I am assuming that each record is of fixed size.
Based on this assumption, i have a better solution.
Since the timestamp is going to be increasing order , we can do a mechanism similar to a binary search by using file pointers using functions like fseek(). Since we know how many bytes each record is taking we can seek the pointer to the middle of the file. For getting the file size , we can use fstat() function.

- Anonymous May 16, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Why wont you grep?

- Anonymous May 24, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

Amazon is famous for asking such questions, the obvious answer is some grep or awk command, they dont expect you to try writing a program for something like this.

Read this - sites.google.com/site/steveyegge2/five-essential-phone-screen-questions

- PA June 04, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

sed -n "/^[a-zA-Z0-9]* 0[3 4 5]:.* FATAL.*/p" <logFile

- D February 21, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

You can use a small script:
startdate = 201308091500
enddate = 201308091659
touch -t ${startdate} start
touch -t ${enddate} end
find /my/directory -type f -newer start ! -newer end | xargs grep "FATAL"

- Jibril Touzi August 09, 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