Amazon Kalido Interview Question
Software Engineer / DevelopersTake something from Orange/Apple
If it's an Orange:
- Orange/Apple -> Orange
- Apple -> Orange/Apple (it can't be Apple or Orange)
- Orange -> Apple (what's left)
Similarly for an Apple:
- Orange/Apple -> Apple
- Orange -> Orange/Apple
- Apple -> Orange
take a fruit from (box1)orange/apple -> let it be orange.. as it is wrongly labeled it can never be orange/apple. So it is Orange.
so the remaining two boxes (box1 and box2) can be either orange/apple or apple.
The apple box (say box2) can never be apple itself as it must be wrongly labeled. So it is Orange/apple. So the final box (box3) will be apple... I hope its clear.. :)
Answer is 1 try.
Since all boxes as mislabelled below is the probability...
Box labelled A + O can contain "A" or "O"
Box labelled O can contain "A" or "A+O"
Box labelled A can contain "O" or "A+O"
If you pick "A" from box labelled A+O,
Box labelled A + O, contains "A"
Box labelled O, contains "A+O"
Box labelled A, contains "O"
If you pick "O" from box labelled A+O,
Box labelled A + O contains "O"
Box labelled O contains "A"
Box labelled A contains "A+O"
I think there is a possibility for label being correct..In that case this will not work..
Pick one fruit from the box labeled "Apples and Oranges". Whichever fruit comes out will be the only fruit in that box. So if you pick an apple from it, the box actually contains all apples. The box labeled "Oranges" will have both apples and oranges and the one originally named "Apples" will have both kinds of fruit.
- Neo July 19, 2007