Logic Interview Questions | Glassdoor

# Logic Interview Questions

87

interview questions shared by candidates

## Logic Interview Questions

Sort: Relevance Popular Date

### Analyst at Deloitte was asked...

Apr 27, 2010
 If you get a 20% raise after your first year and now make \$80K, how much did you make your first year? 6 Answers \$80K divided by 1.2 (didn't ahve to actually do the math) easy to approximate in your head. Divide 80 not by 5, but by 6. That is 13 1/3. that's the amount of your raise. So 80 minus 13 1/3 is 66 2/3, your original pay. Check it, it works because 13 1/3 is 1/5th of 66 2/3, which is 20%. Elegant. 80/1.2 = 80/(6/5) = 80*5/6 = 400/6 = 66 + 4/6 = 66 + 2/3 = 66.6666667 Show More Responses It depends if "now" is the time after first year. Now might be 3rd of 4th year which will make it impossible to calculate the amount earned the first year as we don't know how much raise the person got the following years. who the devil knows Another simple way to do this is that 80k is know 120% of original salary. So divide 80k with 120 and then multiply by 100 which is 66666.6667

Feb 21, 2012
 You have three barrels. One barrel is filled with apples, one with oranges, and one with both apples and oranges. Each barrel is mislabeled. You can take out as many fruit as you like form each barrel and look at it. What is the minimum number of fruits you need to remove to correctly label the barrels? 7 Answers Just one. Take a fruit from the barrel labeled apples and oranges. You know this barrel is not the apples and oranges barrel, so whatever fruit you take must be the only fruit in that barrel. The other two barrels are mislabeled, so you can figure out the other two as well. Two. Take a fruit from A+O, if its an O then this barrel is O ...Now take out a fruit from A, if its an O then this barrel is A+O...and the 3rd is by default barrel A One. Start of from A+O, the fruit u pick say O should be the barrel name. now that means that the barrel labelled A can be A+O or A... But since we know that barrels are mislabelled it cant be A. hence, we concluded it to be A+O and the last remaining barrel is A. Show More Responses 1 Trick question, just look inside the barrel... One. Since it's mislabeled, A can be labeled as O or A+O. Similarily, O = {A, A+O} and A+O = {O, A}. Case 1: Take 1 from A+O label, it turns out to be A. Relabel it. We have A, O mislabels left, and A+O, O real labels left. Mislabeled ones can ot be the same as real labels. So the mislabeled O should be A+O and A should be O. Case 2: also choose from A+O, but it turns out to be O. Solving the same as case 1. None, you don't need to move any of the fruit to correctly label the barrels. You need to change the labels.

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

Jan 30, 2010
 You have 25 horses, and you want to know which are the top 3 fastest, but you don't have a stopwatch. You can race the horses, but the track is only big enough to fit 5 horses at a time. How do you find the first, second and third fastest horses using the least amount of races possible? 3 Answers Split the horses into 5 groups and race each of the 5 groups (5 races). After that, you have the horse placements for each group. I laid it out like this: A B C D E 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 5 5 5 5 5 Five columns, one for each group of horses, lettered A-E. Each number represents a horse... say horse A1 is the one that came in first place from group A, C2 is the horse that placed 2nd in group C, and so on. You can eliminate all 4's and 5's from the chart, since we know that there are at least 3 horses that are faster for each 4th and 5th place horse. A B C D E 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 Now race all the 1's (race #6). This will give you the fastest horse from the initial 25. But what about 2nd and 3rd place? Let's say A1 got 1st, B1 got 2nd, C1 got 3rd, D1 got 4th and E1 placed last in race #6. A1 is definitely the fastest horse, but B1 may or may not be. Horse A2 can still be faster than B1- we have never raced them together before. Approach it this way: which horses can we eliminate? Find all horses that we know have at least 3 horses faster than them. We can eliminate D1 and E1, because we know that A1, B1, and C1 are all faster than them. We can also eliminate all other horses in columns D and E below them. We can't eliminate C1, but we can eliminate C2 and C3. We also eliminate B3, since B2, B1, and A1 were all proven to be faster. A B C D E 1* 1 1 2 2 3 The only horses left to race are A2, A3, B1, B2, and C1. (Race #7). The 2nd and 3rd place finishers are then 2nd and 3rd fastest from the original 25. thanks. very nice explanation very nice~calm thinking! hope I can be so calm in an interview!

### Senior Applications Developer at Deutsche Bank was asked...

Feb 14, 2011
 There are 10 stacks of 10 coins each. 9 of the stacks contain coins that weigh 1g each. The other stack contains coins of 2g each. The coins look the same. We have a scale that we can get a measurement of grams from, not a balance. We can use the scale exactly once to weigh anything here from a single coin to all of them. How can we determine which stack is the 2g coins? 4 Answers Weigh these together: 10 coins from stack 1, 9 from stack 2, etc ending with 1 from stack 10. The weight of these will tell you which stack has the 2g coins. Ex: if it's 1st stack: 65g, 2nd: 64g, 10th: 54g Excellent question! A more eloquent answer would be: Weigh together 1 coin from stack 1, 2 coins from stack2, 3 coins from stack 3, etc. Subtract 55 from that total weight to get the number of the stack with the 2g coins. Show More Responses Binary sort 1. Use single coin (I'd drop my stacks *s*) from each stack. Mark them by stack. 2. Place 5 each on both scales; note lower scale. 3. Place 2 coins on each scale, keep one aside; note scale. 4. If scales are at same level the coin NOT on the scale indicates the stack with heavier coins. Done. 5. If one scale is lower place 1 coin on each scale, note lower, identify stack. Done.

### Senior Software Engineer at Ericsson-Worldwide was asked...

Mar 24, 2009
 I had not expected to be asked logic questions, which made me nervous. The first one was a weigh nine items on a balancing scale to find the odd one out in the fewest scale uses 3 Answers Split them into three groups of three, weigh two to determine the odd set out, then split that stack of three into three sets of one, and weigh two to find the single one out, requiring only two scale uses. The above strategy works only if you know whether the odd item is lighter or heavier. If you do not know how it differs, you will need more scale uses. 111-111-114 <--- By weighing any of two sets, you get 114. 1-1-4 <----- By weighing any of two, you can find out 4.

### Engineer at MongoDB was asked...

Mar 5, 2012
 How much water is on the planet (earth)? 4 Answers Google it Basic science books may help here... about 70% of earth is filled with water. But, I guess the question is more geared towards your analytical skills... For a back-of-the-napkin estimate, you could look up the surface area of the oceans, and multiply that by the average depth. That might be good enough. Show More Responses None of the answers given here are particularly helpful...look up 'fermi estimation' -- that is what the interviewer is looking for with a question like this.

### Member of Technical Staff Software Engineer at VMware was asked...

Jan 12, 2012
 Given a series of strings, find the biggest common prefix. 4 Answers /** * Jun Zheng, Rice Univ * Given a series of strings, find the biggest common prefix. * Real question of VMware * Java7; running time: O(n^2) * @param str * @return */ private String biggestPrefix(String[] strs){ String prefix=strs[0]; for(int i=1;i0;i++){ int j; for(j=0;j0)? prefix:"No such prefix!"; } How that works? You are considering "prefix" must come from the very first string, which is not true. In the following string set, the biggest common prefix is "xyzasd" - which this program fails to find! String[] arr = {"MxyzasdNmm", "kxyzasdDodal", "I am a Good Boy", "JadxyznasdM Golmal", "ABCDEF", "ABCDEFGH", "Sunnyvale", "CaliforniaKxyzaszzMon"}; What? Prefix is not started from the very first string? Jesus I cannot read Eng! Show More Responses x = ["Ravite", "Raviteja", "Ravby", "Raviejaain","Ravi" ] #Given String y = x[0] for i in x: if len(i)> len(y): y = i fin = [] y = list(y) for i in range(len(y)): count = 0 for j in range(len(x)): if y[i]==x[j][i]: count +=1 if count == len(x): fin.append(y[i]) else: break if len(fin) > 0: print "".join(fin) else: print "No common prefix in series"

### Support Engineer at A10 Networks was asked...

Nov 17, 2011
 If you have three people standing, all facing the same direction, each person can see the color of the hat of only the person directly in front of them (which can be either black or white). There are two hats of each color (four total). The hats are placed on the persons' heads one at a time, starting with the one in the very front. When someone knows for certain what color hat they have, they need to declare that they have discovered the color of their hat. In this scenario, no matter which hats are distributed, at least one person can be certain of their hat color. What are these scenarios, and what are the probability distributions for each? 3 Answers the person which is standing in MIDDLE can answer correct. the reason is,since the last person is not answering the colour of his hat,it means he can see two different colours of hats in front of him.so the person standing between them has to conclude that the colour of his hat would be just opposite of the person's hat,standing in front of him. samar's answer would be correct if the problem allowed each person to see hats being worn by *ALL* people in front of them. However, the original question posted said "each person can see the color of the hat of *ONLY* the person *DIRECTLY* in front of them." I think the original question was incorrectly worded. As it is stated, I don't think anyone can know the color of their hat, since nobody has more than one piece of information to start with. There is also the problem of assuming the hat are placed on the head of each in alternate colors otherwise, the last person would see 2 of the same color in front of him thus giving him the solution to his color, providing the person sees both person in front of him as well

### Q & A Analyst Training Program at Eze Software was asked...

Apr 26, 2010
 Scenario: If you were running late for a job interview and you had no lights on in your apartment. Let's say you went into your dresser drawer and had to pull out one pair of socks. All you had was black or brown socks. And there were 5 socks total, what is the least amount of pulls you could do? 4 Answers basically you have to keep in mind the probability of pulling out each sock. the shortest answer would be 2 pulls. You have to pull out three socks to be sure that you had at least two of one color. it would have to be three socks because if you pulled just two, you could get one black and one brown. Show More Responses it's 2. You could be lucky and get 2 socks of the same color.