Myntra Interview Question for Senior Software Development Engineers


Country: India
Interview Type: In-Person




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

You forgot to say that you have only 2 eggs.

Keep doubling the floor you try with first egg.

Try first, 2nd, 4th, 8th, ....

Finally it will break at some 2^(k+1) th floor

But it didn't break on 2^k floor.

Now linear scan from 2^k to 2^(k+1) with second egg.

Might be better ideas?

- GENIUS February 20, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

In case there are only 2 eggs.
Lets say we have N floors and I choose a constant step size of x
No of steps to find the floor where it breaks = N/x + x
First part to identify the block size where it breaks
Second part to check for each floor in the block to identify the exact floor where it breaks
Now its just a problem of minimizing it which can be solved by differentiation, which gives x = sqrt(N)

In case of infinite eggs binary search is the right option.

- kr.neerav February 20, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

There is one more dimension to this problem. It is the number of tries you are allowed.
There are three variables here -
1. No. of eggs - k
2. No. of floors - n
3. No. of tries allowed - q

This problem will then have an optimal substructure property and the recurrence will be the following -
MR is the function calculating the same -

MR(q,k)={1for k=0∨q=0
MR(q−1,k−1)+MR(q−1,k) for k>0∧q>0
MR(q,k) is the maximum number of floors 0..n−1 we can have ,if we have q tries and k eggs to break.

Note that MR(q,q+1)=MR(q,q) because the additional jar cannot be used.MR(q,q)=2^q.

- DE2.0 February 23, 2014 | Flag Reply


Add a Comment
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.

Learn More

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.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More