Mixing Cookie Flavors
Updated
Problem statement
You bake cookies cookies. Each cookie gets one of flavors flavors, and you may use any flavor as often as you like.
Cookies with the same flavor are identical, and the order of the cookies does not matter. So a mix is just how many cookies get each flavor. A flavor may be used zero times.
Return the number of different mixes.
Function
countCookieMixes(cookies: int, flavors: int) → longExamples
Example 1
cookies = 6flavors = 3return = 28This is the interview case: six cookies and three flavors. A mix is three counts that add up to 6, such as (6, 0, 0), (2, 2, 2) or (1, 0, 5).
Line up the six cookies and place two dividers among them to split them into three flavor groups: that is choosing 2 of 8 places, 8 × 7 / 2 = 28.
Example 2
cookies = 2flavors = 2return = 3Two cookies and two flavors: both of the first flavor, one of each, or both of the second. That is 3 mixes.
Example 3
cookies = 4flavors = 1return = 1With only one flavor, every cookie has that flavor, so there is exactly 1 mix.
Constraints
1 <= cookies <= 301 <= flavors <= 20
More Susquehanna International Group (SIG) Online Assessment questions
- Catch Fish with Reusable BaitsOA · Seen Nov 2026
- Bold Play to Reach a GoalOA · Seen Nov 2026
- Cats, Truth and Who Has MoreOA · Seen Nov 2026
- Counting Cows by Their LegsOA · Seen Nov 2026
- Enough Muffins for the LineOA · Seen Nov 2026
- Expected Consecutive Pairs Among Chosen NumbersOA · Seen Nov 2026
- Four-by-Four Boundary GridOA · Seen Nov 2026
- Frog Paths Without Long RunsOA · Seen Nov 2026
- Higher Roll, or Lose the SumOA · Seen Nov 2026
- Is a Popular Story Fake?OA · Seen Nov 2026
Similar questions at other companies
- Count Nondecreasing Digit-Sum ArraysMicrosoft · OAMicrosoft interview questions
- Stable Workload Redistribution TreesTower Research Capital · OA
- Count Valid A-B-C Sequences Under a Modulo-Four RuleInfosys · OAInfosys interview questions
- Count Shipment SchedulesMorgan Stanley · OAMorgan Stanley interview questions
- Count Permutations Without Three Equal Parities in a RowGoogle · OAGoogle interview questions
- Find Encrypted NumberAmazon · OA
- Valid PasswordsMathWorks · OAMathWorks interview questions
- Coloring HousesSnowflake · OASnowflake interview questions
- Find Maximum Number of StringsMoveworks · OAMoveworks interview questions
- Count Distinct Binary Search TreesC3.ai · OAC3.ai interview questions