## Flipkart Interview Question for Software Engineer / Developers

• 0

Country: India
Interview Type: Phone Interview

Comment hidden because of low score. Click to expand.
5
of 5 vote

Instead of taking equal intervals, we can increase the number of floors by one less than the previous increment.
For example, let’s first try at floor 14. If it breaks, then we need 13 more tries to find the solution. If it doesn’t break, then we should try floor 27 (14 + 13). If it breaks, we need 12 more tries to find the solution. So the initial 2 tries plus the additional 12 tries would still be 14 tries in total. If it doesn’t break, we can try 39 (27 + 12) and so on. Using 14 as the initial floor, we can reach up to floor 105 (14 + 13 + 12 + … + 1) before we need more than 14 tries. Since we only need to cover 100 floors, 14 tries is sufficient to find the solution.

Therefore, 14 is the least number of tries to find out the solution.

Comment hidden because of low score. Click to expand.
0

But if we use divide and conquer approach, we only require 6 or 7 number of probs only to find the strength, yours method require 14 , how can it be a good method

Comment hidden because of low score. Click to expand.
0

If you use divide and conqueror you will need additional eggs. However in this case we have only two.

Comment hidden because of low score. Click to expand.
2
of 2 vote

Given N find value of K such that K + (K-1) + (K-2) ..... + 1 = N or least K such that sum is just above N for eg if N = 100 ans will be 14 because 14 + 13 + 12 .... + 1 = 105

Comment hidden because of low score. Click to expand.
1
of 1 vote

In fact, not only 2 eggs, m eggs can be solved by dynamic programming.

Comment hidden because of low score. Click to expand.
0
of 0 vote

let there be N story building

Throw first egg from Xth Floor
if (egg does not break)
then throw egg from (2X)th Floor
continue it up to egg does not break
if egg breaks at i*Xth Floor
the strength of eggs is between {(i-1)*X + 1}th to {i*X - 1} floor
**********MAX N/X iteration
now take 2nd egg and throw it one by one until it break
**********Max X-2 itration

total MAX iteration T = N/X + X-2 ---------(1)

USE
dT/dX=0; ------------MAXIMA AND MINIMA

dT/dX= -N/(X^2) + 1 = 0
X = N^.5

so total no of iteration = 2(N^.5) - 2

Comment hidden because of low score. Click to expand.
0

we can do it better.

first take an egg and drop it from 2nd floor.
if it breaks then drop the second egg from 1st floor.
now if it breaks,
the egg has not enough strength and the ans is zero.
if it does not break,
then the egg has strength 1.
similarly try for all the multiples of two for the pair of eggs u have.

This can be done still better if he wants.
try multiples of three.

Comment hidden because of low score. Click to expand.
0

The answer is correct, your comment is not. You always have to consider the worst case solution for this kind of problems.

Comment hidden because of low score. Click to expand.
0
of 0 vote

Optimal solution is O(sqrt(N))
You can find it by searching for "Google Interview Puzzle : 2 Egg Problem"

Comment hidden because of low score. Click to expand.
0
of 0 vote

Its a 2 lists skip list with sqrt(n) items in first list at an interval of sqrt(n) items in second list

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

### Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

### Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.