Bloomberg LP Interview Question for Software Engineer / Developers






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

(A) It's a case of binary search. Randomly divide 10 coins into two groups of 5 each. Now weigh them. Group containing the oin with lesser weight will weigh less. This is one weigh. Now take that group and randomly pick any 4 coins and divide those 4 coins in two group. Again weigh them: Two cases are possible:

[1] They will be equal, which means the remaining coin is the one which weigh less. You can get the answer in 2 weighs in total in this case.
[2] One will weigh less. Pick that group and again weigh. One of them will be the coin with lesser weigh. You can get the answer in 3 weighs in total in this case.

(B) Pick any 8 coins randomly and divide into two groups of 4 each. Two cases are possible:

[1] First, the easy one. They will weigh same. In that case, one of the two remaining coins contains the odd one. Let the two remaining coins be X1 and X2. In this case, remove 2 coins from one group and one coin from another group . Pick one randomly from X1 and X2, let it be X1, and add it to the group containing one coin. If they weigh same, X2 is the odd one out or X1. Total number of weighs is 2.

[2] If they don't weigh the same, then remove two coins randomly from the first group and 2 coins from the second group. Now, two cases may happen. Either they will weigh same or not. If they weigh same, throw them away and pick the other group of 2 coins. If they donot weigh the same, continue. Now, again remove 1 coin from each of the group. ... if the two group weighs the same, then odd one is from the two coin removed, repeat the last steps of (B)[1] . Though in this case, we are use 4 weighs.

- Anonymous May 18, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

(B) 03 weighs total

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

(A)divide in grps of 3,3,4 n den u can do it in 3 weighs

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

A. Divide in 4 groups consisting 3,3,3 and 1 coins. Weigh 3,3. The odd coin can be in one of these groups or may not be. If the weights are not same, you get the lighter group of coins. You have narrowed down to 3 coins in 1 weigh. Now do the same with groups of 1,1,1 coins. So in 2 weighs you have the answer. If the odd coin is not in the initial 3,3 group. Then it can be in the 2 groups of 3,1 You can find the odd one in 2 more weighs at the max.

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

My main question with this one is whether or not you're given a balance scale (comparing A to B) or one of those newer, digital style ones where you can weigh only one thing at a time. If it's a balance scale, its easy, just split into halves and select the lightest group each time. If it's not, then I don't know.

- Anonymous September 01, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

are you kidding me?

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

If it's not a balance scale then determining which group is heavier takes two weighs. If it's not a balance scale its only possible to do this problem in 4 weighs, and it is impossible in three.

- Ernest April 30, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Can someone let us know how can it be solved in 3 weighs for case B

- sag October 01, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Can someone let us know how can it be solved in 3 weighs for case B

- sag October 01, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Case B: Divide up the coins 3, 3, 3, 1. Measure two groups of 3 coins.

If the initial weights differ, then take note which group is lighter and which is heavier. Take the lighter group and measure with the remaining 3 coins. If the weights are equal, then you know the special coin is heavier and if the weights are different, the special coin is lighter. For the last weigh, just measure any two coins of the group containing the special coin to find the differing coin.

If the initial weights are equal, replace one group of 3 coins with the remaining group of 3 coins. If they now differ, the newly added group of coins contains either the heavier or lighter coin and you can just measure any two coins from this group. If all 9 coins just measured are the same, the last coin is either heavier or lighter, so just measure it with any other coin.

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

Great Explanation. Thanks.

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

in both cases we need max 3 weighs.

- Sandip February 15, 2017 | Flag Reply


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