NVIDIA Interview Question for Software Engineer / Developers






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

pick any 6 balls divide them into 3 each.
if they are same check the rest two and you will find the heavier.
if they are not same then choose 3 from heavier bowl and pick any two and weigh them, if they are same third one is heavier otherwise its clear.

so you have to weigh only two times.

- Punit Jain May 06, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
3
of 3 vote

Split balls into three sets: 2x sets of 3 balls each, and 1x set of 2 balls

First scale step: compare both sets of 3 balls. If one side is lighter, that 3-balls set goes to second step. If both sides are same, the set of 2-balls goes to second step.

Second scale step: If chosen set has two balls, just weigh and pick the lighter. If chosen set has 3 balls, compare any two and pick the lighter one, if they are same, then the third ball in the set.

- nd_100 March 15, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

plain common sense.. take 6 balls apart, split into 3 and 3. if scales are equal, measure the other two remaining balls. if scales not equal, choose any two from the heavier set and measure with one on each side. if equal, third ball is different, else the one where scale moves.

- Anonymous May 22, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Awesome nd_100 thanks

- Akhil April 08, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

idea is good.. but it takes 4 steps... instead.. it will be done it 2 steps...

- Rakesh jain October 26, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I feel this is even simpler: - 2 sets x 4 balls = less groups. 1) Place one set of 4 balls on scale - record weight
2) Place second set on scale- record weight. = The group with the smaller weight hence has the smaller ball.
3) Divide the heavier group by 4.
4) From the lighter group of 4- Place 2 random balls on scale. = If this number is half of the homogeneous set then disregard
5) Chose the the group of in which is not eliminated by common factor- Drop one ball on the scale and if this is a factor then it is the seventh identical ball.

4 physical steps. If you can precisely do it easier please post!

- Clayton May 23, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

there are 2 cases this:
make three sets 3,3,2. scale 3,3
case 1: if both are equal, take set of 2 and take the ligther one. here the task completes in 2 steps.
case 2: if both are not equal, take the set of 3 which is lighter, now take any two out of those. if 2 are equal the left one will be the lighter.

- swatsy May 27, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

2 weighings needed
ceil(log3(8)))

It will be ceil( log3(n) ); n=number of objects
where ceil (1.1) = 2;
log3(n) => logrithm of n with base 3.

- abhityagi85 January 11, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

plain common sense.. take 6 balls apart, split into 3 and 3. if scales are equal, measure the other two remaining balls. if scales not equal, choose any two from the heavier set and measure with one on each side. if equal, third ball is different, else the one where scale moves.

- Anonymous May 22, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

How about if you have N balls , then how many steps does it take to find the heavier one , and how do you find it ?

- Umar Khayyam August 25, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

2 weighings needed.

and the logic is ceil(cube root of n) where n is the number of balls. it will work for all the cases.

- Shunmugasundaram January 22, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

how to find 2 heavy balls from 8 balls...and weight of 2 heavy balls is same...??

- ankit April 08, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

number of steps tends to be cube root of the number of balls.
separate the initial set into three groups, one for each side of the scale and one to be kept aside.
if the scale shows equal, you know the lighter one is in the set set aside.
if the scale tips one way, you know the lighter is in the set that the scale tipped away from.
solve recursively.

- M March 15, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Why cant we have two sets and then weigh it?

- Anonymous March 15, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Always 3 groups,coz you can eliminate 66% in one weigh.
Guys,reply if you have different idea?

- Roshan Mangal March 17, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

the cube root logic doesnt hold i believe

- abhityagi85 January 11, 2012 | Flag
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.


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