Bloomberg LP Interview Question


Country: United States




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

Maintain a Doubly liked list along with the HashMap. See java docs for How LinkedHashMap is used implementing the LRU.

- balani.kunal June 10, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I gues in comparisson to "common" hash tables is necessary to solve colisions in different way - not append new item but prepend (shift collision chain)...

- tpcz March 15, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I meant if the url exists already, then it should be moved to the top of list...

@tcpz: can u elaborate please??

- rahul.jain215 March 15, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Use a hash table along with a queue.
Hash table contains the URL along with its node address.
In hash table, you can check the presence of the current URL and if it is present, move that node to front of the queue else allocate a new node to that URL and place it in front of the queue.

- aasshishh March 15, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Create a hash table along with a string variable.
This string variable will contain the recent URL.
While displaying the URL list put the URL stored in this variable as first in the display list.

- mailtarunjain March 15, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I solve the problem in following ways

Create a b+ tree,use dates are separating elements,
    first level is used for year, 
    second is for months 
    and third is day,
and at day store each URL by linked list which is both way,  after linked list use hash table to directly file the URL, 
             this is used to maintain the constrain that each url can only comes only once, 
actually this does not happens, like in google crome, they don't have above constrain.

Now when every user click on a url , 
first we check weather the clicked url is present or not ?, 
     if not present then we insert it into tree and create new entry in hash table, 
           It is like two indices on a database. so data is same for both indices. 
     Now if url already present then we remove that element from linked list and create new node at first node and join it.

so this require constant time for insertion, searching , deletion etc.

- sonesh March 15, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

You can create a hashtable with key as integer and value as string.
When hashtable is empty insert the url as string with key as maxofInterger (2,147,483,647) and decrement the key for every new and latest entry but if the entry exists delete it and create new with new hash value or change the key to the latest key.

- vish1310 March 25, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Hash table shouldn't care about order.
Create a hash table along with max heap.

- Anonymous May 08, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Yes!

- Alan October 19, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

It would help if someone points out if my solution is right or wrong!
We could add each entry where the key is a timestamp specifying when the user clicked on the URL and the value being the URL itself and the hashtable could implement a comparator to order the items based on key in descending order.And returning topmost element in the hastable would give the most recently used URL
Since the question specifies it has to be an implementation with hash table,solutions such as using a queue or maxheap would mean it can be done only with a queue or max heap alone and hashtable would not be required!

- chan1450 May 31, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I agree that browser needs time stamps (for displaying the history and erasing some of it). So I guess, I would have an unordered map (which is based on hash-table) of URL's with time stamps as keys, and I also would have a list of the same time stamps (or pointers to them in the map) in chronological order. The end of the list would be considered the "top" of it mentioned in the task.

- igorfact July 07, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 2 vote

use splay tree

- ashfaq July 02, 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