Pergunta de entrevista da empresa Google

First Person: Simply high level questions about how to achieve certain things. For example: 1) How would you write a pancake sort routine 2) You have a network of friends (linked in friends, facebook friends, etc). How would you keep track of all the people you are connected to. 3) What is the run time of the A* search (only because I mentioned it somewhere along the line). Second person: 1) Write code to find duplicates in a linked list 2) How would you synchronize a linked list across multiple computers. If nodes are added/removed to a linked list on one computer, all others must reflect this change. Concurrancy must be accounted for

Resposta da entrevista

Sigiloso

4 de mai. de 2013

(duplicates in a linked list) public static ArrayList dups(LL l) { ArrayList dups = new ArrayList(); Hashtable h = new Hashtable(); while (l != null) { Integer count = h.get(l.v); if (null == count) { h.set(l.v, 1); } else if (count.intValue() == 1) { h.set(l.v, 2); dups.add(l.v); } l = l.next; } return dups; }