# Developer Interview Questions

# 412K

Developer interview questions shared by candidates### A frog is at the bottom of a 30 meter well. Each day he summons enough energy for one 3 meter leap up the well. Exhausted, he then hangs there for the rest of the day. At night, while he is asleep, he slips 2 meters backwards. How many days does it take him to escape from the well?

106 Answers↳

Never....the frog would be dead by day 10 since nothing to eat or drink.

↳

I agree -- it's 28...because on that morning, he'll be at 27 metres and he can jump to the top in one bound. Less

↳

Assuming it doesn't die of starvation, the answer is 28 days.* start of day 1 (0 days elapsed): 0m --> 3m (then falls back 2m by start of day 2) start of day 2 (1 day elapsed): 1m --> 4m start of day 3 (2 days elapsed): 2m --> 5m ... start of day 28 (27 days elapsed): 27m --> 30m start of day 29 (28 days elapsed): 28m --> 31m In other words, 28 days will have elapsed before the frog can jump to a height exceeding 30m.* * This answer assumes the frog is not able to walk away after it hits 30m. I would assume it has no energy left to climb out based on the problem description. If the questioner disagrees with this assumption, then the answer is 27 days. Less

### Out of 25 horses, pick the fastest 3 horses. In each race, only 5 horses can run at the same time. What is the minimum number of races required?

63 Answers↳

7 races. We run five races with five horses. The five winners race in a sixth race while the 4th and fith place finishers are eliminated from further consideration. The sixth race show horse is faster than all the horses that participated in the preliminary races where the 4th and 5th place horses participated and they are eliminated from further consideration. The other horses in the preliminary race where the 6th race show horse participated are also eliminated. The show horse in the preliminary race where the 6th race place horse participated is eliminated since there are at least three remaining horses that are faster. We are left with 6 horses. We know the winner of the 6th race is fastest overall, so that leaves five horses to enter a 7th race for the overall place and show. Less

↳

Seems to me the correct answer is five. Assuming that each horse's performance is timed, by running five races with five horses each, you'll know the speed of all 25 horses. The three with the shortest times are the three fastest horses. Most responses assume you need multiple rounds, but these responses seem to assume that the five horses that finish first in the first round are the fastest five overall. That may not be the case. Just because a horse beat its four competitors doesn't mean it's one of the five fastest overall ... just that it was faster than the four it competed against. Less

↳

dynamitemike's answer is the one. A timer could be considered but the problem would be pointless if you had a time. Run 5 races, let's say, Hij denoting the j-th rose in the i-th race, 1 <= i <= 5, 1 <= j <= 5. Eliminate the last two, since there will be three or more horses faster than them for sure. We are left with 15 horses. Run a 6th race with the Hi1 (the 1st placed horses). Suppose the results are Ha1, Hb1, Hc1, Hd1 and He1. The fastest horse in this race (Ha1) is the fastest horse of them all. The last two (Hd1 and He1) can also be eliminated because there will be three or more horses faster than them for sure (at least the top 3 of the 6th race). At this point, we have 12 horses to consider. But the 2nd and 3rd places horses in the preliminary races of the two worst placed horses (Hd1, He1) in the 6th races (Hd2, Hd3, He2, He3) can also be eliminated since there will be at least three horses faster than them. We have only 8 horses left. What about the 2nd and 3rd places horses in the preliminary race of the 3rd placed horse (Hc1) of the 6th race? There will be at least three horses faster than them (Ha1, Hb1 and Hc1). They can be eliminated. We have 6 horses left. Following the same reasoning, the 3rd placed horse in the preliminary race of the 2nd placed horse (Hb1) of the 6th race can be eliminated because there will be at least three horses faster (Ha1, Hb1 and Hb2). We have 5 horses left, namely Ha2, Ha3, Hb1, Hb2 and Hc1. These horses will run in the 7th race and the top 2 will join Ha1 and they are the top 3 horses among the 25 initial. Note that the maximum numbers of races required is MAX = 1 + (H - R)/(R - T), if you have H horses, if you can use R horses per race and if you want the top T horses among all H. For H = 25, R = 5 and T = 3, MAX = 11 races. You get to this result simply through successive races eliminating the last two (R - T) and adding the same number of horses until all of them have raced. It is an exhaustive "brute force" approach. Less

### Calculate the angle of two clock pointers when time is 11:50.

61 Answers↳

30+25=55 angle between them...

↳

You know that there is 30 degrees between each number on the clock because 360/12 = 30. You know that the minute hand is at exactly 10, while you know that the hour hand is 5/6th of the way to the 12 (from the 11) because 50/60 = 5/6. Therefore to get the total angle, you must add the 30 degrees from the 10 to 11 plus the 5/6 distance from 11 to 12, and you get 30 degrees + (5/6 * 30) = 30 + 25 = 55 degrees. So the final answer is 55 degrees. Less

↳

Anonymous is on the right track with the hour hand going 0.5 degree/minute, but at 11:50 the hour hand is no longer near the 11, it's near the 12. 10 minutes before 12, it is 5 degrees from the 12. The minute hand is 60 degrees from the 12 in the same direction (360 deg=60 minutes, so 60 deg=10 minutes). Angle between the hands is the difference between these two: 60-5 = 55. Less

### How many people flew out of Chicago last year?

62 Answers↳

Actually the answer is zero. Plans fly, people don't.

↳

Roughly as many who flew into Chicago.

↳

My estimate off the top of my head is 30 planes/hr x 24 hr/day x 365 days/yr x 180 people/plane (avg) = 47M and change. Actual for 2014, Domestic and International, is 70M. This is Passenger Volume so # leaving is 35M. Less

### Suppose you had eight identical balls. One of them is slightly heavier and you are given a balance scale . What's the fewest number of times you have to use the scale to find the heavier ball?

47 Answers↳

Two. Split into three groups of three, three, and two. weigh the two groups of three against each other. If equal, weigh the group of two to find the heavier. If one group of three is heavier pick two of the three and compare them to find the heaviest. Less

↳

2 3a+3b+2 = 8 if wt(3a)==wt(3b) then compare the remaining 2 to find the heaviest if wt(3a) !== wt(3b) then ignore group of 2 discard lighter group of 3 divide the remaining group of 3 into 2+1 weigh those 2 If == the remaing 1 is the heaviest if !== the heaviest will be on the scale Less

↳

2 weighings to find the slightly heavier ball. Step 1. compare 2 groups of three balls. Case 1. if they are both equal in weight, compare the last 2 balls - one will be heavier. case 2. If either group of 3 balls is heavier, take 2 balls from the heavier side. compare 1 ball against the 2nd from the heavy group result 1. if one ball is heavier than the other, you have found the slightly heavier ball. result 2. if both balls are equal weight, the 3rd ball is the slightly heavier ball. Easy Shmeezi Less

### There are three boxes, one contains only apples, one contains only oranges, and one contains both apples and oranges. The boxes have been incorrectly labeled such that no label identifies the actual contents of the box it labels. Opening just one box, and without looking in the box, you take out one piece of fruit. By looking at the fruit, how can you immediately label all of the boxes correctly?

46 Answers↳

Swaz answer is almost correct however it does not work in all scenarios. lets assume: box 1 is labelled Oranges (O) box 2 is labelled Apples (A) box 3 is labelled Apples and Oranges (A+O) and that ALL THREE BOXES ARE LABELLED INCORRECTLY" Pick a fruit from box 1, 1) if you pick an Orange: - box 1's real label can only be O or A+O - box 1's current label is O - since ALL LABELS ARE INCORRECT then box 1's real label can not be O - box 1's new label should then be A+O by elimination - since ALL LABELS ARE INCORRECT - box 2's label is changed to O - box 3's label is changed to A - SOLVED 2) if you pick an Apple: - box 1's real label can only be A or A+O - box 1's current label is O - since ALL LABELS ARE INCORRECT then box 1's real label can not be O - this still leaves us with the choice between label A and label A+O - which would both be correct - FAILURE Solution: The trick is to actually pick a fruit from the A+O labeled box Pick a fruit from box 3: 1) if you pick an Orange: - box 3's real label can only be O or A - box 3's current label is A+O - since ALL LABELS ARE INCORRECT then box 3's real label can not be A+O - box 3's new label should then be O by elimination - since ALL LABELS ARE INCORRECT - box 1's label is changed to A - box 2's label is changed to A+O - SOLVED 2) if you pick an Apple: - box 3's real label can only be O or A - box 3's current label is A+O - since ALL LABELS ARE INCORRECT then box 3's real label can not be A+O - box 3's new label should then be A by elimination (not O) - since ALL LABELS ARE INCORRECT - box 1's label is changed to A+O - box 2's label is changed to O - SOLVED Less

↳

All the three boxes are names incorrectly. SO the bax lebeled Apples+Oranges contains only Oranges or Only Apples. Pick one fruit from it. If it is Orange then lebel the box as Orange. So the box lebeled Oranges contains Apples and the remaining contains both. Less

↳

It's easier to draw it out. There are only 2 possible combinations when all labels are tagged incorrectly. All you need to do is pick one fruit from the one marked "Apples + Oranges". If it's Apple, then change "Apple + Orange" to "Apple" The "Apple" one change to "Orange" The "Orange one change to "Apple + Orange" If it's Orange, then change "Apple + Orange" to "Orange" The "Apple" one change to "Apple + Orange" The "Orange" one change to ""Apple" Less

### Allergy,posting date according to timezone,person demographics problem Medication Frequency problem and given error log to identify error Fever temperature problem and discuss a time when you automated a task to make life easier

43 Answers↳

For some questions answers are posted in glassdoor!

↳

Hi...did you answer all the questions correctly?? They asked me the same questions. I have answered the programs correctly except that fever program there i got bit confusion.but I couldn't properly explain the error log. Less

↳

Hey i didnt answer all the questions correctly ..they helped me if i am struck .. Less

### attributes of <tr> tag

41 Answers↳

please let me know if anyone got Job

↳

36. If you get call then follow this interview experience

↳

please let me know if any one get offer after 3rd Round .

### What is machine learning, difference between dl and ml?

39 Answers### Puzzle: How do you weight an elephant without using a weigh machine?

39 Answers↳

Not quite. The volume of the water is not the same as the weight of the elephant. You'd have to estimate the density of an elephant and multiply that by the volume of the water to get the mass, then multiply that by the acceleration due to gravity in water system (SI, English Customary, etc.) you're using. Luckily, mammals are mostly water (humans are around 70% water on average), so about 2/3 of the weight of the elephant would be equivalent to the weight of the water displaced. So you would have to estimate how dense the rest of the elephant is (since it'd be minerals and such, I'd say it's more dense than water) and follow the steps described above. Less

↳

As it is not specified that the International System of Units must be used, define the Elephant unit (E) as the weight of your elephant. Your elephant then weights exactly 1E. Less

↳

Simple answer : Use a beam balance . Put elephant on one side and start throwing weights on the other side . When the beam is balanced you got the weight of the elephant equal to the sum of weights on the other ! Less