Microsoft Interview Question for Interns

• 0

Country: United States
Interview Type: Phone Interview

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

always picking from the basket labelled "mixed".

If picking an apple, this "mixed" is actually apple basket, the one labelled "orange" is actually mixed basket. The left one is orange basket.

If picking an orange, the one labelled "mixed" is orange, the one labelled "apple" is mixed basket, and the left one is apple.

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

how can we say that : if picking an apple, this " mixed" is actually apple basket????

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

@zil: Because all labels are incorrect. "Mixed" can only have apples, or oranges, but not mixed.

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

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

Take a fruit from the Basket#3.
If the fruit picked is Apple, take the "Apples" label from the Basket#1 and place it on Basket#3 and we are done.
Basket#2 will be labelled with "Mixed", Basket#1 will be labelled as "Oranges" from the fact that all baskets are labelled incorrectly.

Same logic goes in case the fruit taken turns out to be Orange.

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

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

okay... So lets pick from basket 'Mixed' (it can be either Orange or Apple, as its not mixed)
Case 1 : its an Orange
Result : Now, 'Mixed' becomes 'Orange', and we left with two baskets, Orange & Apple, label 'Orange' as 'Apple' and 'Apple' as 'Mixed' because we know they are wrongly labeled and we already got Orange basket in first step.

Case 2: we got an apple
Result : mark 'Mixed' as Apple, and A -> O and O -> M

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

``Excellent answer``

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

Box# : Box1, Box2, Box3
Label# : Apple, Orange, Mixed
Let's pick a fruit from Box3 (Labeled as Mixed). Now, as per the problem statement this box is not actually a mixed one which means it is either an orange box or an apple box.

Case 1: if the fruit which we picked happens to be an Orange:
1. Box3 is Orange Box
2. Box2 which is labeled Orange is actually Apple box
3. Box1 is actually a mixed box.
for this case the Correct Order is written below:
Box# : Box1, Box2, Box3
Label# : Mixed, Apple, Orange

Case 2: if the fruit which we picked happens to be an Apple:
1. Box3 is Apple Box
2. Box2 which is labeled Orange is actually Mixed box
3. Box1 is actually an Orange box.
for this case the Correct Order is written below:
Box# : Box1, Box2, Box3
Label# : Orange, Mixed, Apple

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.