# Brain teaser Interview Questions

interview questions shared by candidates

## Brain teaser Interview Questions

You have 1 seat left on a flight, and you have 5 passengers waiting on standby, a military man in uniform, a pregnant woman, a woman and her infant child, an elite customer(one who is a frequent flyer of NWA), and a gentleman trying to go an see his ill sister. Who will be the one to get the empty seat on the flight, and why? 8 AnswersUnless it is life or death, our Elite customers always have preference, they are frequent flyers and therefor they are providing alot of revenue for the airline. Not the pregnant woman, if she may be in fear of labour, it would be best she delay her flight not hurry-up and get on. Not the woman with infant because there is no priority here except being polite perhaps. Same with the man visiting his ill sister (didn't say it was life/death situation) It is true that NWA gives preference to the frequent flyers and would normally be the one to get the seat HOWEVER the Military man, IF he is on active duty and believes there is a threat to the aircraft and/or may involve National Security (which may in-effect mean life or death) would get the seat- I believe that post-911 this supersedes ALL normal procedures at any US airport or may or may now be included in the new procedures. The first one to get on the standby list. Show More Responses Isn't this the decision for the boarding gate agent, not the flight attendant. it's my first try to assist to a pregnant women in getting a seat in first. It would be the man who is a frequent flyer I would give it to the military man on the basis that his service is a part of the reason we get to fly back and forth whenever we want and need to freely. The first thing it is the gate attendants decision not the flight attendants. But the one who should get the seat is the passenger who has the family member that is ill. That family member may be terminal and that passenger may need to get to his destination as soon as possible. |

If you have a three gallon jug and a five gallon jug No marks on either one The goal is to fill the five gallon jug with four gallons of water How is this accomplished? 5 AnswersTake 5 gal. and pour into the 3 gal. The 5 now has 2 gal. Empty the 3 gal, and pour the remaining 2 gal into the 3 gal. Fill the 5 gallon and pour 1 gal. (which is the remainder of the space in the 3 gal.) This gives you 4 gal. that was from die hard 3. 1) fill up the 3 and pour it into the 5. 2) fill up the 3 and fill up the rest of the 5. that leaves 1 in the three. 3) dump out the 5. 4) pour the 1 that's left in the three into the 5. 5) fill up the 3 again and pour it into the 5. see - easy peasy. might be a bit rougher if solving it is necessary to stop a bomb from blowing up the city. mclain and samuel L got it done. 1) Fill up half of 5 gal (2.5 gal) from 3 gal jug 2) Fill up half of 3gals jug(1.5 gal) and pour into 5gal jug 2.5 + 1.5 = 4gal Show More Responses Die Hard 2 also has the solution to this question. there are actually 4 die hards, which is why you two are confused. 1. the classic big LA building he runs through glass 2. the airport based one 2*. the new york fed gold gets stolen (die hard with vengence) -- THIS is the one with the water puzzle. 3. the newest die hard where the stop lights get taken over etc, live free die hard i think |

### Software Developer at Bloomberg L.P. was asked...

Can't remember the details, but was asked a question regarding dropping eggs off high buildings to determine the height at which an egg would first break. 5 AnswersActual Question The question is you have two eggs and a building that is 100 ft tall. The egg will break on an integer at height greater than or equal to 1ft or less than or equal to 100ft. You have 2 drops to find out what the highest point is at which you can drop an egg without it breaking. What is the fewest number of drops it would take to find the 'breaking point.' Actual Answer 14 Explanation Drop from 14 ft, if it doesn't break add 13 ft, then 12 ft, etc...till you get to 99 (After adding 4). If it doesn't break at 99, you know the answer is 100ft. If at any point it breaks, you would drop it at a hight 1ft greater than the last drop point from which the egg did not break. You keep dropping from 1ft higher until it breaks. At no breaking point is it possible for it to take more than 14 drops. This works for any height between 1 and 100 as long you add 1 less foot to each additional initial point where the egg did not break. This works because the total maximum drops after the first break at each initial dropping level decreases each time an additional initial drop is required. There is also some mathematical theory or algorithm that explains this. Example 1: Breaks at 14ft (first drop), you test heights 1ft - 13ft. If the breaking point was 13ft, It took only 14 total drops to find this point. Test any other height. if the question is like JH said, why not just use binary-search algorithm? the worst case is 7 times. Example: drop at 50, if it break, drop at 25, if it doesn't break, drop at 37,and so on. DId I misunderstand the question or not? http://en.wikipedia.org/wiki/Dynamic_programming#Egg_dropping_puzzle Show More Responses you can't use binary search because what if you drop it at 50, it breaks, and then you drop at 2, and it breaks again? then you have 2 broken eggs and no answer =\ http://www.datagenetics.com/blog/july22012/index.html |

### Software Engineer at TripAdvisor was asked...

Write a program that given 4 coin denominations and a dollar amount finds the best way to express that amount using the coins given. I.e. you have coins with denominations of 1c, 7c, 13c,19c and you have to express $2.12 with the least number of coins. There is always a 1c coin but the other 3 are arbitrary. 6 AnswersTurns out , this problem only has an elegant solution when the coin denominations are divisible by each other, such as the US coins (1, 5, 10, 25). Otherwise, it requires a (slightly optimized) brute force algorithm. I was told so by the interviewer after struggling with it using different approaches for about 40 minutes. If you have a coin of value 1, you can use a greedy algorithm: always select the most valued coin, until you have less money left that this value. Remove the coin, try again with less coins and the money left. Otherwise, just bruteforce and memoization, to implement a simple dynamic programming approach where you want to minimize the number of coins used, caching on the amount of money left to divide. Greedy algorithm is not right at all for general cases. This is a very classical questioin. If you fail on this question, I would say that it is probably your fault. Show More Responses In all my years of giving and receiving interview questions I have never seen this one. It is definitely NOT a classical programming problem. Asking whether a candidate knows of an obscure academic puzzle does not sound like a good interview question. int main() { int currency[] = {19,13,7,1}; int money = 212; int i=0; int div=0; while (money>0) { div = money/currency[i]; money = money%currency[i]; if(div>0) { cout It is a classical programming question that derives from the first fit decreasing algorithm in discrete (decision) mathematics. |

### Ios Software Engineer at Facebook was asked...

One question 3 of the interviewers asked me was "What was the most difficult thing you had to deal with.". 6 AnswersThink about it first, it's hard to remember all what you did in a few seconds. Be ready to brag about your experience, your achievements, what you're proud about. Overall I feel like what is rewarded is you as you are. What you did is a proof of what you are. I don't even hold a bachelor degree, and never worked in a fancy company before. What were they especially looking in an iOS engineer? Did you code everything in Objective C? My understanding is that they are looking for reasonably excited people, who can solve medium-hard algorithm problems (not crazy ones, kinda array sorting and stuff), and know well their language and platform (in our case iOS/Objective-C). And yes, all was in Objective-C. At some point I asked if Python would be more adapted, they insisted I do all in Objective-C. I just feel Objective-C is a little heavy (syntax wise) for algorithm problems... Good luck :) Show More Responses Thanks for answering. I am crossing my fingers for the upcoming interview. Just be relaxed for your interview day. You'll visit Facebook, maybe buy some stuff at the store, eat great food :) it's a very fun day! And you'll chat with brilliant engineers! Good luck!! Did you answer the same everytime this question was asked, or you thought of a different problem to tell to some interviewers? |

### Software Developer at Microsoft was asked...

Why is a manhole cover round? 6 AnswersSo it won't fall into the manhole. i dont believe all this , i have been to interviews and nobody asks these questions, its usually 1 question per person you talk to and thats it .. not all such questions please. its something that was asked 20 years ago. Now its simple and everything depends on how you are liked as a person ... its a very biased process, i was offered and i declined its a bad place now. for easy transport.... rofl it ... oh sorry roll it Show More Responses I think everyone has seen this in Parade magazine at least once. If someone really asked me this in an interview I think I would suggest that it was time for them to retire. http://en.wikipedia.org/wiki/Manhole_cover Reasons for the shape include: * A round manhole cover cannot fall through its circular opening, whereas a square manhole cover may fall in if it were inserted diagonally in the hole (A Reuleaux triangle or other curve of constant width would also serve this purpose, but round covers are much easier to manufacture.) In reality, however, the existence of a "lip" holding up the lid means that the underlying hole is smaller than the cover, so that other shapes might suffice. * Round tubes are the strongest and most material-efficient shape against the compression of the earth around them, and so it is natural that the cover of a round tube assume a circular shape. * Similarly, it's easier to dig a circular hole and thus the cover is also circular. * The bearing surfaces of manhole frames and covers are machined to assure flatness and prevent them from becoming dislodged by traffic. Round castings are much easier to machine using a lathe. * Circular covers do not need to be rotated to align them when covering a circular manhole. * Human beings have a roughly circular cross-section. * A round manhole cover can be more easily moved by being rolled. * Tradition. * Supply. Most manhole covers are made by a few large companies. A different shape would have to be custom made. So it rolls off your toes after you drop it |

Given 10 cups to locate the bottle poisoned wine from a batch of normal ones, you can make any mixture of them and test your mixtures by mouses. However the density of poison in the mixture, the testing mouse will certainly die. And you must give all the mixtures of the 10 cups before the test. There is only one poisoned bottle. How many bottles of wine you can test at most? 5 Answers2^10 You judge from the result of test. There is 2^10 kinds of possible conditions and each of them leads to a different result. So you can tell from 2^10 bottles. The mixtures are made as: 1. label all the 2^10 bottle from 0-1023 in binary numbers. 2. for each numbers, if any of the figures is 1, then mix this bottle into the corresponding cup. Like bottle 0000100101(2) =37(10) , figures in place 6, 3 and 1 are "1", so mix this bottle of wine into cup 1, 3, & 6. If and only if the mouses of cup 1, 3 and 6 die, the poisoned bottle will be 37. I solved it a different way, but got the same answer -> 2^10. Start with base cases and work up. 1. If you have one glass, can have at most two bottles one poison, one not (if mouse dies, the bottle is poisoned. if mouse doesn't die, it's not poisoned and the untested one is) 2. Two glasses, four bottles one bottle untouched, one bottle in glass 1, one bottle in glass 2, one bottle in glasses 1 & 2. (similar idea: if no mice die, first bottle is poisoned. if mouse 1 dies, second bottle is poisoned. if mouse 2 dies, third bottle is poisoned. if both mice die, fourth bottle is poisoned) 3. 3 glasses, 8 bottles distributed as follows: - 1 bottle untouched - 1 bottle in glass 1 - 1 bottle in glass 2 - 1 bottle in glass 3 - 1 bottle in glasses 1 & 2 - 1 bottle in glasses 2 & 3 - 1 bottle in glasses 1 & 3 - 1 bottle in glasses 1, 2, & 3 4.... All the way up to 10 glasses seems a bit garbled. just put wine from one bottle in one cup, and give it to the mouse. if he dies, you are done. if he lives, add wine from a second bottle and give it to the mouse. repeat until the mouse is dead. the last bottle you opened is the poisoned one. hard to believe the question was actually worded that way. Show More Responses I also came with the same answer in a different way. if n bottles, then make mixture of n/2 bottles and test, you would know which half the poisoned bottle belongs to. Next take n/4 and n/8 and so on. so log2(n) = 10 , n = 2^10 Notice that "you must give all the mixtures of the 10 cups before the test.", so you cannot test them one bottle by one bottle or half of bottles in one time |

### Software Engineer at NetApp was asked...

Two trains, each moving at 20 miles per hour towards each other, are initially 60 miles apart. A bee starts at the front of one train, flies to the other train, then back to the first train, and so on. If the bee always flies at 30 miles per hour, how far does the bee fly before the trains collide? 5 Answers45 miles. He was laid back about this question and wanted to see me thinking about it more than getting it right. time of collision=30/20=1.5hr distance fly by the bee= 30X1.5= 45miles 45 miles is the wrong answer. The end points for the bee are constantly changing, so you can't just say 30X1.5 Show More Responses @72min ..the bee collides with first train and starts traveling back @30miles/hour...when trains are 6 miles apart from collision point.. @90 min the collision occurs...so bee has 18min to travel from its collision in opposite direction...so 30mph * 18/60 = 9 miles towards collsion point(which is 6 miles apart). So it will be far by 3 miles. Other possibly correct answers: - The bee would die from the sudden impact with train 2 in 72 minutes after flying a total of 36 miles. - Oh you mean these bees have mastered inertialess flight - forget about the job and give me one of those to study! That aside... The one thing everyone left out of the answer was that enough information wasn't actually supplied to answer it 100% accurately and it has nothing to do with the fact that the two endpoints are moving. The issue is that while the 45 miles number may be "close enough" - to be 100% accurate you have to calculate the total number of traversals the bee can make in the time allotted and subtract it's body length 1 time for each of those traversals from the total. |

I was asked a pretty straight forward brain teaser during my last phone interview, which they said they don't normally do, but because I put that I was a logical problem solver on my resume they couldn't resist the opportunity to. It was the following "There are 20 different socks of two types in a drawer in a completely dark room. What is the minimum number of socks you should grab to ensure you have a matching pair?" 5 Answers3 is the answer when the probability is 50% for either color. "20 DIFFERENT socks of two type" In my opinion It's a brain teaser not a probability question. The answer is none. There is no sock alike, so you can't get a pair. 3 is the answer no matter what... there are only 2 types, if you grab 3, you must have 1 of one type and 2 of the other Show More Responses I'm not a mathematician, statistician or highly analytical but if you pick up 3 socks they could still be all the same type - even if the odds are 50%. Odds do not equal reality. So the only way to "ensure you have a matching pair"is to pick up 11 of the 20. This is the only fool proof guaranteed way to get a pair (in the real world and not the world of odds). All of the previous answers are somehow wrong or misleading. "Not-a-mathematician": the method you describe would ensure that you get 2 DIFFERENT socks instead of matching - and only in the situation that the ratio is exactly 50-50. "Anonymous on Oct 20 2012": No, you could also have 3 of the same sock after grabbing 3. "Anonymous on Oct 3": The probability has little to do here, while it is over 0%. THE REAL ANSWER: Given that there are 2 types, and you want to get a MATCHING PAIR (not 2 different socks) you must grab 3. When you have 3, you WILL have at least 2 of the same kind, since there are only 2 kinds available. |

### Consulting at Cambridge Associates, LLC was asked...

How many baseball's can you fit on a 747? 4 AnswersWork through the question.. they just want to see how you approach a problem and analyze it. There is no right or wrong answer, they just knew i liked baseball and thought it would be good to see me talk through the problem. One thing that I don't quite understand. The 747 is somewhat cylindrical, which means that the top of it is rounded off, as in, not flat enough to hold any baseballs without them falling off. So, you attempt to put a baseball on top of a 747 and it will probably just roll off wouldn't it? Then you actually can't put any baseballs on top of a 747. Anyway, I don't know if this is the right answer, or if there even is one, but that's my analysis of the situation. This type of question is about demonstrating your thinking process and your comfort level with estimation. Here's one approach: 1. Estimate the width and height of the fuselage (main body of the jet). It's roughly a cylinder, so you could assume that the width and height are approximately the same. (Maybe 20 ft.) 2. Now estimate the length of the fuselage. (Maybe 150 ft.) 3. I can't remember the formula for the volume of a cylinder, but the formula for the volume of a cube is length x width x height. In this case, 20 x 20 x 150 or 60,000 cubic feet. 4. Now estimate the number of baseballs in one cubic foot. (Maybe four high, four wide, and four long, or 4 x 4 x 4, or 64. 5. Now multiply 64 baseballs per cubit foot by the number of total cubic feet on a 747 (60,000) to get approximately 3,840,000 baseballs. Show More Responses Hey Steve I think you are thinking about volume- This type of question intrigues me because there are so many unstated variables such as, is there adhesive of some sort involved? Does "on" mean "all around" or covering the 747? If there is no adhesive, does that mean 'how many baseballs could you put on TOP of the 747' - does this also include the wings? And would it count if there is no adhesive material and one rolls off - as Curio stated, it is not a flat surface. Actually there are a million other hypothetical questions that could pertain to the imaginary baseball on the 747, but the interesting part for me is to read each post and determine what 'controlling statements' each person adds to the question before answering it. It is so easy to simply answer a hypothetical question with predetermined figures based on each persons thinking process or experience, instead of taking only the facts stated in the question and determining a hypothetical answer or two. I am thoroughly enjoying reading these questions, posts, and analyzing thought responses. Sometimes I am even enlightened. ;-) |