Amazon Interview Question for Software Engineer / Developers
- -1of 3 votes
Given a log file from a website which contains the user ID and the accessed URL, find the TOP "sequence" of 3 urls amongst ALL visitors of the website. The sequence of urls have to be in sequence as they are accessed.- Guy January 24, 2014 in United States
My solution is Two hashtables and one MaxUrl object. One hashtable<String,String> userName as key and url sequence as value, where url sequence is three url contatenated by a special character like '#' (google#amazon#yahoo). This value is in FIFO manner. For each value, we check with the second hashtable and see if they exist before, if yes, increment the count, if no, insert the new sequence with count set to 0. So second hashtable<String, Integer> url sequence as key and count as value. Keep a curr_Max to store the current max count, when exceeded, updates max_urlSequence.
| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Data Structures
Interview Type: In-Person
Open Chat in New Window