Today i had a round of interviews with google. Here are the puzzles that they asked.

1) Write a generator() and checker() method. The generator method genrates unique IDs. The checker method checks whether the ID that it receives is correct. (both of them could reside in different machines for example.) Note: no meta data can be transferred along with the generated id to the reciever. Assume that the generated id is 6 digits. The checker() method should be able to detect if there has been a change of even a single digit that has been transferred from the generator method. You need to find out the subset of all the six digit numbers that can be generated as IDs. For example, if the question was for 2 digit numbers then the valid subset would be "11, 22, 33, 44.. 99". These numbers when generated as IDs can be detected by the checker() method when received to see whether the generated ID was correct or not. Even if a digit changed, then it could be found. You need to find the satisfying condition for 6 digit numbers to form an ID. Also, find out how many such 6 digit numbers are possible.

2) There are two dice. One dice has numbers labeled from 1 to 6. Other die given to you is a blank die. You need to label the other die in such a way that each time you roll both the dice,the probability of getting a value between "1 and 12" (note: 1 and not 2) is the same.

3) You have an x-y plane on which you have "n" number of points. You need to write an efficient algorithm to find out the maximum number of points that are collinear.

4) You have a singly linked list whose size you do not know. Write an algorithm which picks up a random node from the linked list each time with equal probability(but node chosen once should not be chosen again). You should not traverse the linked list fully once to know the size of the list.

Subscribe to:
Posts (Atom)