Oracle Interview Question: You have 10 boxes of balls (e... | Glassdoor

Interview Question

Senior Software Engineer Interview Redwood City, CA

You have 10 boxes of balls (each ball weighing exactly

  10 gm) with one box with defective balls (each one of the defective balls weigh 9 gm). You are given an electronic weighing machine and only one chance at it. How will find out which box has the defective balls?
Answer

Interview Answer

2 Answers

4

Take 1 ball out of the 1st box, 2 balls out of the 2nd, 3 balls out of the 3rd, etc.... and then weigh all of the balls. Then take the total weight = 10*total number balls + x. Solve for x and that will tell you which box is defective.

devpaul on Mar 7, 2013
0

Above answer is not correct.

Approach is correct. So if you take 1 ball, 2 balls, 3 balls ...etc from all 10 boxes, you will have 55 balls. Now the weight of each ball (non defective) is 10 gm. So assuming there are no defective balls , the weight of 55 balls would be 55 X 10 gm. But since there are some defective balls, which we do not know how many are, let us say Z, we need to subtract that weight from 550 gm. So 550 - (weight of each defective ball) X number of defective balls Z. The equation would be 550 - 9Z = weight shown by weighing machine. Solve for Z.

Mrudula on Nov 10, 2016

Add Answers or Comments

To comment on this, Sign In or Sign Up.