We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
P(A) + P(B) = 130 (this is one possible distribution)
Remember that we have two people, so we can repeat coefficients up to two times each. We can therefore construct any permutation of the list [1,1,2,2,3] to multiply elementwise with the prices. It's simply a matter of choosing the most advantageous order to purchase.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Greedy Florist
You are viewing a single comment's thread. Return to all comments →
A purchases (1)100 + (2)7 + (3)1 = 100 + 14 + 3 = 117
B purchases (1)9 + (2)2 = 9 + 4 = 13
P(A) + P(B) = 130 (this is one possible distribution)
Remember that we have two people, so we can repeat coefficients up to two times each. We can therefore construct any permutation of the list [1,1,2,2,3] to multiply elementwise with the prices. It's simply a matter of choosing the most advantageous order to purchase.