Interview Question for Software Engineer / Developers






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

4 is the answer, apply pigeon hole principle.

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

4? if i pick 3 consisting of 1 red, 1 blue and 1 yellow i will need just one more so that i will hv two of the same color..

- Anonymous October 22, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

If u can pick the one u like, y don't u just pickup any 2 of the same color? :-)

I think, u cannot see the color while u r picking up. Assume u r blindfolded (or in dark), then how many beans u need to pick?

- Hari Prasad Perabattula October 22, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Um, it's still 4 even if you're picking blindfolded. After you've picked 3, the 4th one HAS to match the color of one of the 3 you've picked before!

What he seemed to be trying to say was that in the worst case, the first 3 will turn out to be of different colors. The best case is 2 when it just so happens that you pick both of the same color (blindfolded or not!).

- Anonymous November 01, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

4 should be the answer. I think question should be modified using word "atleast" . Correct me if I'm wrong

- vaibhav19jbp October 22, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

4 is the answer. 49 is the answer for two different color.

- Anonymous October 22, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Yes, got the question wrong. 4 for the 'same' color. 49 for the 2 different colors.

- Hari Prasad Perabattula October 25, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

17...correct me if i am wrong

- the sage December 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

yes, 17 is wrong. 4 is the correct answer..... You just need 4 chances to pick two balls of same colors, provided any color.....
If there is a constraint that you should have 2 of red or 2 of blue or 2 of yellow, then we have to use the probability ratios otherwise, we don't even have to care about the probabilities.

- shekhar2010us February 10, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

whats the fuss about this problem its simple..........4

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

pigeonhole principle .. if you guys know .... answer : 4

- raj February 24, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Hey guys..if u saying it as 4 then you are assuming tht ur picking 1 color each time for first 3 then 4th one will be one among the previous...i dont know pigeon hole but you are making an assumption here, aren't you. why cant we pick 2 of same colors in straight 2 picks..so answer will be 2 then,

and if you can explain who you apply pigeon hole principle it will be great...

- sriks March 31, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Umm, no, this is the case when we have an equal probability of picking either of the balls, here the probability is different, 1/16, 1/32, 1/48..so the answer is not 2. It is more than 2.
Its easy to understand if you think of it this way. Out of every 6 balls you pick, 3 will be yellow, 2 blue and one red.

So ans = 1/6*2/6 +2/6*3/6 + 1/6*3/6 = 11/36

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

now this is really lame.

- pritesh July 26, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

now this is really lame.

- pritesh July 26, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Its a concept of simple Pigeon Hole Principle !
So much discussion for this !

- F10 May 04, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

there are 3 colors so you must pick 4. You cannot get 4 different colors. Worst case the first 3 are different colors and the fourth must match 1 of the 3.

To get guaranteed 2 different colors you must pick 49 because the first 48 may all be yellow

- Anonymous June 18, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

2 in the best case...
17 in the worst..

- Anonymous March 08, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

49?

- Anonymous October 22, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think its 49.

We're sure that there would be at least 2 when we pick all.
Starting from here,

1). We can safely drop 16 (In the worst case, all the red beans are missed).
2). Of the remaining (after the worst-case), we can again drop 31 (all can be blue in the worst case).

Total - (31+16) = 49.

Correct me if I'm wrong.

- Hari Prasad Perabattula October 22, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

you are wrong

- Anonymous December 04, 2010 | Flag


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