Donation

If you found the contents in this blog useful, then please make a donation to keep this blog running. You can make donations via Skrill with email address shazin.sadakath@gmail.com

Wednesday, August 22, 2012

Amazon.com Interview!!!! Yeah you heard it, Amazon.com! - 2

Thanks to all mighty god. I got through the first phone interview and was emailed on 17/08/2012 by Kristin to schedule a second phone interview. Usually Amazon has 3 phone interviews prior to an onsite interview. I fixed the next interview to be on Yesterday (21/08/2012) at 9.00 a.m. PT which is 9.30 p.m. local time.

A Software Development Engineer named Pascal Schoenhardt phoned me and he asked some General Questions first. Followed by a technical question which was;

How to traverse a binary tree level by level.

my answer was in Pseudo Code

Function traverse(Node n)
       list.add(n)
       
       while(list not empty) 
           Node n = list.get()
           Print n.value
           
           if(n.leftChild not null)
               list.add(n.leftChild)
           if(n.rightChild not null)
               list.add(n.rightChild)

He seemed ok with the answer. Then he asked me whether I had any questions and I asked about the work environment at Amazon. He explained alot and it seems like a fun place to work in. Then he gave me a Take Home question and asked me to reply to his Email Address the Solution. The problem was


Given:

A log from a website, where each line is a 2-or-3 element CSV sequence containing:
SessionID,Page URL,[Optional Error Code]
The error code field will be populated if an error occurred while the page was loading.
    
Problem:

Parse the log, and produce a list of three page sequences in which lead to an error, 
sorted by occurrance (highest first). That is, every time an error occurs, if the 
sessions in which it occurred has at least two previous successful page loads, we 
have a new three page sequence leading to an error. We are only interested in three 
page sequences. The customer may continue to browse after encountering an error.

Assumptions:

- You have a function getNextLogLine() which returns a CSV string, or null if the end of the log is reached.
- You may assume that you have all of the standard data structures available to you in library form.

Example:

Log File
    123,/products/a.html
    456,/products/a.html
    789,/products/d.html
    789,/products/a.html
    123,/products/b.html
    789,/products/c.html
    456,/products/b.html
    789,/products/d.html,Err2
    123,/products/c.html,Err1
    456,/products/c.html,Err1

Sample Output:            (3 page sequence)                (err)  (count)
    {/products/a.html, /products/b.html, /products/c.html}, Err1, 2
    {/products/a.html, /products/c.html, /products/d.html}, Err2, 1


I was staying awake and wrote the solution and mailed him back with the answer. The interview was a great experience and as always I am thankful to god for giving me this opportunity.


No comments: