# Analytical Interview Questions

interview questions shared by candidates

## Analytical Interview Questions

### Assistant Trader at Five Rings Capital was asked...

You are standing beside a road watching cars pass by. The probability that you see a car pass by in 1 minute is 1/4. What is the probability that you see a car pass by in 30 seconds? 8 Answers1-sqrt(3)/2 why is this let p=probability that you see a car in 30 seconds p(see car in first 30 seconds)=p p(see car in second 30 seconds)=p p(see car in the first 60 seconds)=2p-p^2=1/4 solving you get p=1-sqrt(3)/2 (reject 1+sqrt(3)/2 since it's over 1) Show More Responses I have a question on this solution: 1-(1-p)^2 is the probability of seeing at least one car, not the probability of seeing a car. You can also solve this using exponential distribution. From the question, you can deduce that the distribution has to be memoryless and hence there has to be a constant rate per unit time for the event to occur. Let the probability per unit time of a car passing by be p. Then from the given information 1/4 = 1 - e^{-p*T} The required answer is e^{-p*T/2} which gives the answer as reported above. Minor correction in above. The required answer is 1 - e^{-p*T/2} ans 1/2 as the person sees car in 15 sec of each 1 minute if we divide 1 minute into 4 parts (60/4 = 15 secs) s the probablity of seeing car now we are asked in 30 sec . the rate of moving of car will not change it will still continue to come at a rate of 1 in each 15 sec so the ans for each 30 sec would be 1/2 if we divide 30 into 2 parts . so in 15 sec one car is left .but for next 30 sec no car is going to come then itls probability would be 0 . now the ans is tricky which 30 secs are asked , the 30 sec in which car is seen or in which it is not seen by the man 1 - sqrt(3)/2 is the wrong answer |

### Software Engineer at Google was asked...

You have a genealogy: 1) Describe a data structure to represent it. 2) Given any two people within the genealogy, describe an algorithm to determine if they share a common ancestor. You just need to return true/false, not all ancestors. 6 Answers1) Each person is represented by an object, with two pointers: "mom" and "dad" that point to their respective parent. 2) Choose one of the two people arbitrarily. Perform depth-first traversal and create a set of ancestors reachable from that person. Perform depth-first traversal on the 2nd person and for each node visited check if they are in the set; if yes, return true. Use a hash-set for best performance. calculate the height of person 1 in the tree, calculate the height of person 2. Move them up to be the same height. Then keep going until they intersect. @user: Its not a tree. A genealogy is a graph due to the fact that you have maternal and paternal trees intersecting. Therefore there is no root from which to calculate height. Show More Responses If you've optimizing for worst case, hash set is O(n) for search. You'd do better in worst case with a sorted structure. You'd do even better if you store a "visited" flag at each node. Alternately you can number each node and keep an array of visited flags. since depth first seach might find a longer link through dad before checking mom, you're better off with breadth first search. Anything reachable in one hop would be seen before anything reachable at best in 2 hops Yes. Good points. The second traversal should be breadth first. The first traversal it doesn't matter, as you need to visit all ancestors anyways. The use of a visited flag is a good optimization. Based upon the way the question was worded, it wasn't clear if you could design the data structure to optimize the algorithm or not. I belive both the first and second should be BFS traversals |

### Inventory Specialist at Apple was asked...

What was the hardest thing you ever had to do in your prior work experience? 7 AnswersLeave Climb out on a ledge in order to weld a beam no harness 50 feet up, nothing to hold onto once my welding helmet goes down and i lean over. I got out there and couldn't make myself let go. I was walking on a 3" wide beam. I failed. my scared ass had to get another idiot to do it. lol I worked in starting based organisation. There were v.less seniors. So, if there is any issue, I alone did R&D and resolved it. Though, I took time to resolved, but that made me aware of many scenerios and gave confident boost. Show More Responses Travel to Hawaii to fire a rep. It was bad because there was no time to stay and relax. The owner insisted that I return immediately! Had to terminate a female employee who was badly injured from a fire. It had been proven via testimony to us that she covered herself with gasoline and lit it off to get even with a boyfriend, but she said it was due to an accidental kitchen fire. Fire Marshall report also verified she was not telling truth. Our policy said no coverage from 'self-inflicted' incidents and she had lied to us about the cause of the fire. As I told her she was being terminated, I was looking at a melted face, and compresses on each of her arms, and in a torso cast. This was three months post incident and investigation. You don't feel good after a day like that one! This is a comment. Steve... wow. THAT'S not hard... that's unreal. The hardest thing I had to do is doing something for others |

### Software Engineer at Amazon was asked...

Given a (potentially large) array of integers, all but one repeating an even number of times, how would you find the one repeating an odd number of times in an efficient way? eg [1 2 3 3 2 2 1 4 2] should return 4 7 AnswersUse any collection data structure to insert and remove the numbers, such that at the end the only one remaining will be the one repeated an odd number of times. For example we can use a tree. We consider on number at the time. We first search for the number in the tree. If found, we will remove it. Otherwise, we will insert it. At the end, the number (or the numbers, in general) repeated an odd number of times will be in the tree. For the complexity it is necessary to perform an amortized analysis. Another data structure that we can use is the hashmap. However, the space consumption and management could be high, if the map automatically resizes. Ex-or the numbers. For the odd occurrence, the ex-oring will not result in zero. Ex-oring is a great idea, one other solution is to sort the array and then in one pass you can find out the number that occurs odd number of time with quicksort avg case nlogn and worst case n^2 Show More Responses Few steps of counting sort can help us do it in O(n) time. Step I: find min and max, thus the range Step 2: initialize array of the range with 0 Step3: as numbers come in, increment the a[number] by 1. Step4: scan the array to find the odd number. Ex-or is a good solution only if 0 is not in the input list. If 0 occurs odd number of times, not sure it will report it. Tellig about zero is an excellent catch.. +1 by using LINQ it can be acheived. var numList = new List() {1 ,2, 3, 3, 2, 2, 1, 4, 2 }; var oneOccurance = numList.GroupBy(x => x).Where(y => y.Count() == 1).Select(y => y.Key); //Ans = {4} |

Another was a puzzle: A king orders 100 bottles of wine for a celebration. A courtier who's angry with the king over something puts poison in one of those bottles. The king has a way of identifying the poisoned bottle by giving a few drops of wine to a monkey. Since the poison is fast acting, the monkey will die immediately. Whats the minimum number of monkeys needed to find the poisoned bottle? 6 AnswersAssuming that there is only one poisoned bottle, then you only need one monkey- because as soon as it dies, you found the bottle. However, if there is more than one bottle, or suspicion of more than one bottle, you will need at least two monkeys. you need only one monkey since you will keep giving him wine till he dies and as soon as he's dead you know that was the bottle. I think it means we can only test once. So the minimum # of monkeys is 99, is it? Show More Responses The answer is 7. Let monkeys be numbered 1-n. Each number less than or equal to 100 can be written as a 7 bit number. Hence, bottle one(0000001) is given to monkey 1. bottle three(0000101) is given to monkeys 1 and 3 and so on. Now say monkeys 1 3 5 died, it means that the number is 0010101 which means the bottle 41 is the poison! The way it's written, it seems like one would be the answer, or perhaps considering a monkey's tolerance for wine, N = 100 / (number of drops of wine a monkey can drink before passing out)... When asked with the condition that the monkey will die some time later, i.e. not immediately, the binary number technique described by Sri Krishna is best. make the courtier drink it |

### Summer Analyst at Goldman Sachs was asked...

How do you check if a Linked List has a recurring loop? 4 AnswersI thought of using a hash table to store the values of each node, and adding values to the table as we iterate through the Linked List. This would only work if the values are unique. It was the not fastest or best either. With some hints, I came to a better solution of iterating through the Linked List twice - one that hops 1 node each time and the other hops 2 nodes each time. If the latter loop surpasses or reaches a node from the first, there exists a loop. There would be no loop of course when both reach the end of the Linked List. There is a blog discussing this problem, as well as another problem to find the entry node in the loop. There is a blog discussing this problem, as well as another problem to find the entry node in the loop. The link of the blog is: http://codercareer.blogspot.com/2012/01/no-29-loop-in-list.html Show More Responses /* Jun Zheng, Rice Univ C++, Xcode 4.5.2 Interview question of GS Check if a linkedlist has circle, phead points to the start node */ bool ifCircular(node* phead){ node* pfast=phead; node* pslow=phead; while(pfast !=NULL && pfast->next !=NULL){ pfast=pfast->next->next; pslow=pslow->next; if(pfast==pslow) return true; } return false; } |

### Specialist at Apple was asked...

What is your main weakness? 4 AnswersAnswer however you like, just be prepared. I wouldn't say I have a weakness but If make a mistake it's my job to learn from it and get better at it. first of all we discover our weakness,when we fail to do/achieve something perfectly.but once we discover it,and we learn to overcome it,it becomes one of our power/ability,so you would better ask what are you'r powers?and they will be achieved during our life course througjh experience Show More Responses The point about this question is to test self-awareness. The answer is not to say "I work too hard" or "too detail oriented" or some other non-weakness answer. The correct answer is to ask yourself what skill does this job not require, and then you pick a weakness from that set of skills for which you give something constructive. Eg. An engineer position does not need public speaking skills. Say you get nervous when speaking to large audiences and you mitigate that by preparing well.. |

### Software Engineer at Pure Storage was asked...

Given two base classes and a class derived from them how might one layout class instance memory so that polymorphism will work correctly. Problem was simplified in that one could assume memory was a series of same-sized slots and methods and attributes took up one slot each. 3 AnswersI thought I did rather well, as I figured out (with some help) all but one aspect of the problem. hello , could you expand a little on the question and what you cam up with ? No, I can't really elaborate. It has been almost 3 years, the solution was convoluted, and I think I have blocked it out, since I don't remember much. I believe it involved having place holders for methods and attributes in the base class that carried over to the derived class. But I'd suggest a good compiler book, some time with the C++ compiler, and hours to kill if you really want to know the full answer. |

Can you fill in for a system manager.` 3 AnswersYes, was my answer. Absolutely, i can fill in for a system manager. When I worked for ORU admissions, the office manager and the system manager both left and I took over for both of them. |

How to come out of a maze given that you can move one step at a time and you cannot turn left. 3 AnswersRelies on the fact that if you keep your one hand on the left side then you would eventually come out of the maze. i cant understand what you mean. but here is what i think: when u want to turn left, make 3 right turns; means, instead of doing a 90deg antiClockwise, do a 270deg clockwise. start: if open to the right or blocked, then turn right go forward one if possible go to start unless done |