Problem Statement
- "ice cream","banana","chocolate","chocolate","peanuts"
- "ice cream","banana","chocolate","chocolate","peanuts"
- "ice cream","banana","chocolate","peanuts"
- "ice cream","banana","chocolate","chocolate"
- "ice cream","banana","chocolate"
- "ice cream","banana","peanuts"
Definition
- Class:
- DessertMaker
- Method:
- countBananaSplits
- Parameters:
- String[]
- Returns:
- int
- Method signature:
- int countBananaSplits(String[] ingredients)
- (be sure your method is public)
Constraints
- ingredients will contain between 1 and 30 elements, inclusive.
- Each element of ingredients will contain between 1 and 50 characters, inclusive.
- Each element of ingredients will contain only lowercase letters and spaces ('a'-'z',' ').
Examples
{"ice cream","banana","chocolate","chocolate","peanuts"}
Returns: 5
The example from the problem statement.
{"banana", "banana", "chocolate", "strawberries", "pineapple", "pineapple", "rice cream"}
Returns: 0
To make a banana split, you need "ice cream", "banana", and at least one other ingredient. We have a "banana" and plenty of other ingredients, but we don't have an "ice cream" so we have zero possibilities.
{"ice cream", "ice cream", "banana", "banana", "chocolate", "chocolate"}
Returns: 8
To see the 8 possibilities, note that you can pick either one or two "ice cream"s, one or two "banana"s and one or two "chocolate"s (and 2*2*2=8). You cannot have no ice cream or no bananas - and we need to have at least one other ingredient so we need at least one chocolate. Note that {"ice cream","banana","chocolate"} counts as a different dessert than {"ice cream","ice cream","banana","banana","chocolate","chocolate"} because the ingredient list is not identical.
{"foam", "apple", "whipped cream", "apple", "mushroom", "apple core", "ice cream", "ice cream", "banana", "giraffe", "mushroom", "spare tire", "ice cream", "banana", "foam", "wrench", "paper", "cherry", "alarm clock", "football" ,"apple", "apple"}
Returns: 138234
You don't know if it'll be good until you try it.
{"ice cream","banana", "a","a","a","a","a","a","a","a","a","a", "a","a","a","a","a","a","a","a","a","a", "a","a","a","a","a","a","a","a"}
Returns: 28
{"ice cream","banana", "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","aa","bb"}
Returns: 268435455
The maximum answer.
{" ice cream","ice cream ","ice cream","ice cream ","banana","banana","ice cream"," "}
Returns: 60
{"banana","i c e c r e a m","icecream","ice cream","r","s","t","l","n","e"," "," "," ","ice cream"}
Returns: 4095
{"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij", "abcdefghijabcdefghijabcdefghij", "abcdefghijabcdefghijabcdefghij", "abcdefghijabcdefghijabcdefghij", "abcdefghijabcdefghijabcdefghij", "abcdefghijabcdefghijabcdefghij", "abcdefghijabcdefghijabcdefghij", "abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij", "abcdefghijabcdefghijabcdefghij", "abcdefghijabcdefghijabcdefghij","abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij", "abcdefghijabcdefghijabcdefghij", "abcdefghijabcdefghijabcdefghij", "abcdefghijabcdefghijabcdefghij", "abcdefghijabcdefghijabcdefghij", "abcdefghijabcdefghijabcdefghij", "abcdefghijabcdefghijabcdefghij", "abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij", "abcdefghijabcdefghijabcdefghij", "abcdefghijabcdefghijabcdefghij","abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij", "abcdefghijabcdefghijabcdefghij", "abcdefghijabcdefghijabcdefghij", "abcdefghijabcdefghijabcdefghij", "abcdefghijabcdefghijabcdefghij", "abcdefghijabcdefghijabcdefghij", "abcdefghijabcdefghijabcdefghij", "abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij", "abcdefghijabcdefghijabcdefghij", "abcdefghijabcdefghijabcdefghij"}
Returns: 0
{"oyjvd", "banana", "wfknj", "banana"}
Returns: 0
{"ice cream", "ice cream", "omymc", "ice cream", "glwdd"}
Returns: 0
{"ice cream", "banana", "banana", "ice cream", "sjyua", "sjyua", "imrgp", "banana", "rgknb", "ice cream", "ice cream", "banana", "ice cream", "fcnnx"}
Returns: 460
{"ice cream", "pzbzp"}
Returns: 0
{"ice cream", "banana", "ice cream", "cnddf", "misvv", "banana", "ice cream", "ice cream", "banana", "ice cream", "vdvlt", "zsile", "misvv", "banana", "ice cream", "xxcob", "banana", "ice cream", "cnddf", "xxcob", "mfmya"}
Returns: 7525
{"banana", "ice cream", "ice cream", "ygnky", "ecmnq", "iohgn", "banana", "iohgn", "bzqer", "zrlxr", "iohgn", "pvizq", "ice cream"}
Returns: 762
{"banana", "idmjj", "ice cream", "banana", "banana", "ice cream", "banana", "ice cream", "wyprp", "zanre", "iddoi", "mjqkk", "tnkon", "ice cream", "wyprp", "iddoi", "ice cream", "ice cream", "ice cream", "sppxj", "vjrnc", "banana", "ice cream", "zanre", "banana"}
Returns: 41424
{"wttsl", "ice cream", "banana", "xnlkj", "banana", "ice cream", "banana", "arywl", "banana", "xnlkj", "ice cream", "crvzx", "ice cream", "fxgkr", "kroul", "banana", "banana", "banana", "banana", "xnlkj", "vusrs", "ice cream", "banana", "vaqjw", "banana", "ice cream"}
Returns: 30660
{"ice cream", "ice cream", "ice cream", "qpfqj", "banana", "ice cream", "banana", "zhhwx", "banana", "banana", "wzvbn", "banana", "rqgta", "plztj", "rqgta", "zhhwx", "errrj", "cjtak", "ice cream", "opfbd", "nyyed", "ice cream", "jxagh", "banana", "banana", "wzvbn", "cjtak", "rqgta", "banana"}
Returns: 331728
{"ngwja", "banana", "banana", "banana", "ysbvj", "banana", "banana", "banana", "fsirm", "fsirm", "kvxds", "ice cream", "ice cream", "banana", "banana"}
Returns: 368
{"ice cream", "xyjki", "banana", "ohwyb", "banana", "banana", "ice cream", "banana", "banana", "nugyp", "xhsgz", "banana", "nfibu"}
Returns: 372
{"banana", "nkesk", "ice cream", "ajysc", "wzbxj", "ice cream", "mopjo", "banana", "ajysc", "ice cream", "banana", "ice cream", "banana", "eowck", "ice cream", "qmrbg", "ice cream", "ice cream", "ice cream", "qmrbg", "mopjo", "ice cream", "galvh", "ice cream", "ice cream", "nkesk", "ajysc", "ice cream", "ajysc", "banana"}
Returns: 64740
{"vixqf", "banana", "banana", "jxnpw", "wydfg", "banana", "ice cream", "ice cream", "eoshe", "ice cream", "jlhxo", "ice cream", "jxnpw", "jlhxo", "ice cream", "eoshe", "gtzxm", "banana", "vixqf", "banana", "banana", "banana", "banana"}
Returns: 12920
{"ice cream", "ice cream", "banana", "iazbt", "ice cream", "wvvuv", "wzccl", "banana", "banana", "banana", "wzccl", "banana", "banana", "wvvuv", "banana", "psuzr", "banana", "ice cream", "tqkpb", "lketl", "ice cream", "xkugx", "ice cream", "ice cream", "wsrnj"}
Returns: 32200
{"banana", "banana", "lyswb", "ice cream", "banana", "abmov", "muowh", "snlwp", "rnspy"}
Returns: 93
{"ice cream", "banana", "ice cream", "ydihq", "enujh", "skqye", "jwcce", "ice cream", "gfbpn", "ice cream", "banana", "hdkes", "banana", "banana", "dqddr", "ice cream", "hdkes", "ice cream", "ice cream", "enujh", "ice cream", "ice cream", "gfbpn", "ice cream", "banana", "ice cream", "fgvcz", "banana", "xdwyo"}
Returns: 113982
{"bkhkb", "ice cream", "mxzal", "banana", "ndqjt", "duins", "ice cream", "ice cream", "ice cream", "banana", "banana", "zvbqp", "banana", "mxzal", "zvbqp", "pwcxy", "pwcxy", "ice cream", "fpbva", "ice cream", "gqyll", "zvbqp", "ojhyt", "ojhyt", "ojhyt"}
Returns: 110568
{"etxbk", "fwoov", "banana", "whezc", "banana", "kusqt"}
Returns: 0
{"ice cream", "banana", "fcwxv", "banana", "ice cream", "ice cream"}
Returns: 6
{"ice cream", "ujmyh", "ice cream", "qnjlh"}
Returns: 0
{"ice cream", "ice cream", "banana", "ice cream", "swqjb", "reqaf", "slqfc", "banana", "xqsej", "banana", "ice cream", "ice cream", "eozsy", "banana", "ice cream", "banana", "xqsej", "banana", "banana", "reqaf", "ice cream", "oskdz", "banana", "banana", "ice cream", "banana", "banana", "fklnk", "ice cream"}
Returns: 28413
{"ice cream", "czzzs", "ice cream", "topqd", "sfgvq", "qjdyi", "banana", "ice cream", "banana", "banana", "banana", "ice cream", "hxjeb", "dsggk", "ice cream", "ixfwr", "ice cream", "oitdl", "qjdyi", "banana", "ice cream", "banana", "ice cream", "ixfwr"}
Returns: 27600
{"gnduh", "glfar", "ice cream", "wwebl", "banana", "ice cream", "xgpkw", "banana", "wwebl", "fkoup", "banana", "xswea", "ice cream", "xgpkw", "fkoup", "ice cream", "ice cream", "dutsf", "xswea", "wwebl", "yinpq", "banana", "ice cream", "yinpq", "ice cream"}
Returns: 72548
{"cfath", "ice cream", "kxaod", "ice cream", "rnell", "ice cream", "ice cream", "ice cream", "ice cream", "banana", "ice cream", "mizvl", "vwcrf", "banana", "banana", "banana"}
Returns: 868
{"banana", "banana", "banana", "xntfl", "banana", "zifll", "banana", "ice cream", "banana", "ice cream", "ice cream", "utdrl", "eyuyh", "banana", "kxrtb", "xmcyb", "banana", "maiho"}
Returns: 3048
{"foam", "apple", "whipped cream", "apple", "mushroom", "apple core", "ice cream", "ice cream", "banana", "giraffe", "mushroom", "spare tire", "ice cream", "banana", "foam", "wrench", "paper", "cherry", "alarm clock", "football", "apple", "apple" }
Returns: 138234