Jelly Beans Jars

You have three jars that are all mislabeled. One contains peanut butter jelly beans, another grape jelly jelly beans and the third has a mix of both (not necessarily half-half mix).

How many minimum jelly beans would you have to pull out to find out how to fix the labels on the jars?

Labels on jars are as follows

Jar 1 : Peanut butter
Jar 2 : Grape
Jar 3 : P.b. / Grape

Answer is a integer. Just put the number without any decimal places if its an integer. If the answer is Infinity, output Infinity.

Feel free to get in touch with us if you have any questions

Hints
  • Solution Approach
  • Complete Solution
3462 successful submissions.
Asked In:
  • Microsoft
Click here to jump start your coding interview preparation